create
and update
actions behave correctly when saving a limerick fails.test/controllers/limericks_controller_test.rb
- controller test file."should not create invalid limerick"
- name of new create
test."should not update invalid limerick"
- name of new update
test.params
to have invalid empty-string values for title
and limerick_text
:
limerick: { title: '', limerick_text: '' }
assert_no_difference
- check that the number of Limerick
objects in the database has not changed.assert_response
- check that the HTTP response has a 422 status code.assert_select
- check that the rendered page contains an h1
element with the appropriate text:
create
test.update
test.assert_not_nil
- check that a flash['error']
message was set.rails test -v
- command to run tests and generate coverage report.coverage/index.html
- coverage report to view in web browser.