Open swt2public opened 3 years ago
Sorry, it's not working for me yet:
When a user visits the new author page Then it should have a text input field with the name 'author[first_name]'
Expected to find field "author[first_name]" that is not disabled but there were no matches
If you have problems solving this task, please don't hesitate to contact the teaching team!
Sorry, it's not working for me yet:
When a user visits the new author page Then it should have a text input field with the name 'author[first_name]'
Expected to find field "author[first_name]" that is not disabled but there were no matches
If you have problems solving this task, please don't hesitate to contact the teaching team!
Scenario
When a user visits the new author page Then it should have a text input field with the name 'author[first_name]'
Hints
The new-author page (it should be at
/authors/new
) looks rather empty, but before adding input fields, create a test that checks their presence.In the spec file (
spec/features/author/new_author_spec.r
), create a newit
block with a descriptive name. Inside the block, after visiting the new-author page, the test should check for input fields.RSpec uses matchers to check if a given object is valid. For example, the
have_field
matcher Checks if the HTML of the page has aninput
form field with the given label, name or id. For more matchers, see this Cheat Sheet or the documentation.The following code snippet shows how your final test should look. You can copy&paste this code, but understand what every instruction does before moving on.
After committing the test, add the form fields (for first_name, last_name and homepage) required by the test. It should look something like this. To create a form within the
views/authors/new.html.erb
view, you can use a form builder, which allows easily generating the required HTML. The primary form builder for Rails is provided by a helper method calledform_with
. See the Rails tutorial.Don't worry if submitting the form causes an
Unknown Action
error at this point.Error
2/44 exercise tests have passed