Add a controller test for the new
action
Task
- Add a controller test to check that the
LimericksController#new
method functions correctly for the happy path.
Steps
- Add Test:
- Controller test file:
test/controllers/limericks_controller_test.rb
- Test name:
"should get new"
- Arrange:
- Retrieve
User
fixture object one
.
- Sign in the user.
- Act:
- Simulate an HTTP GET request.
- URL helper for HTTP request:
new_limerick_url
- Assert:
- Use
assert_response
to check that the response has a success status code (e.g., 200 OK
).
- Use
assert_select
to check that the rendered page has an h1
HTML element with the text “New Limerick”.
Reference Code and Commands
- Terminal command to run tests: