When a user visits the new author page
And fills in 'Alan', 'Turing', and 'http://wikipedia.org/Alan_Turing', respectively
And submits the form
Then Alan Turing should be found in the database
Hints
To test this feature, you need to simulate a user filling in an authors's data into the 'new author' form and submitting it.
In the test, after visiting the new-author page, you can use fill_in to enter data into the input fields.
Using the find and click methods, you can submit the form.
A new it block in spec/features/author/new_author_spec.rb might be helpful.
For more information, see the Capybara reference.
After writing the now failing test, we need to save the form data that is sent to the AuthorsController in an object in the database.
This is the task of a create action in the app/controllers/authors_controller.rb controller file.
Here is the relevant section in the Ruby on Rails guide.
Don't forget about strong parameter and to whitelist the required parameters.
You can can the amount of authors in the database using the rails console (rails console): Author.count.
If you issue a redirect to the author instance (redirect_to), this will lead to an error, as there is no code for showing authors yet.
Scenario
When a user visits the new author page And fills in 'Alan', 'Turing', and 'http://wikipedia.org/Alan_Turing', respectively And submits the form Then Alan Turing should be found in the database
Hints
To test this feature, you need to simulate a user filling in an authors's data into the 'new author' form and submitting it. In the test, after visiting the new-author page, you can use
fill_in
to enter data into the input fields. Using thefind
andclick
methods, you can submit the form.A new
it
block inspec/features/author/new_author_spec.rb
might be helpful. For more information, see the Capybara reference.After writing the now failing test, we need to save the form data that is sent to the AuthorsController in an object in the database. This is the task of a
create
action in theapp/controllers/authors_controller.rb
controller file. Here is the relevant section in the Ruby on Rails guide. Don't forget about strong parameter and to whitelist the required parameters.You can can the amount of authors in the database using the rails console (
rails console
):Author.count
. If you issue a redirect to the author instance (redirect_to
), this will lead to an error, as there is no code for showing authors yet.Error
Estimated progress: 17% complete