Add controller tests for resource-save failures
Task
  - Add non-happy-path controller tests to check that the createandupdateactions behave correctly when saving a limerick fails.
Steps for each controller test
  - Add test:
    
      - test/controllers/limericks_controller_test.rb- controller test file.
- Copy the corresponding happy-path test.
- Rename the copy to reflect the new expectations:
        
          - "should not create invalid limerick"- name of new- createtest.
- "should not update invalid limerick"- name of new- updatetest.
 
 
- Arrange:
    
  
- Act:
    
      - Change the paramsto have invalid empty-string values fortitleandlimerick_text:
          - limerick: { title: '', limerick_text: '' }
 
 
- Assert:
    
      - assert_no_difference- check that the number of- Limerickobjects 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- h1element with the appropriate text:- 
          - “New Limerick” for the createtest.
- “Edit Limerick” for the updatetest.
 
- assert_not_nil- check that a- flash['error']message was set.
 
- Run tests and inspect coverage report:
    
      - rails test -v- command to run tests and generate coverage report.
- coverage/index.html- coverage report to view in web browser.
 
Reference Code
   
  