Reputation: 85
I have searched around and not found anyone experiencing a similar problem, so I would like to post it here.
My tests were all passing until listing 9.40. I have posted all of my files input between 9.40 and 9.46, although I believe I am following the tutorial precisely.
ERRORS:
1) User_pages delete links as an admin user
Failure/Error: it { should have_link('delete', href: user_path(User.first)) }
expected #has_link?("delete", {:href=>"/users/211"}) to return true, got false
# ./spec/requests/user_pages_spec.rb:45:in `block (4 levels) in <top (required)>'
2) User_pages delete links as an admin user should be able to delete another user
Failure/Error: click_link('delete', match: :first)
Capybara::ElementNotFound:
Unable to find link "delete"
# ./spec/requests/user_pages_spec.rb:48:in `block (5 levels) in <top (required)>'
# ./spec/requests/user_pages_spec.rb:47:in `block (4 levels) in <top (required)>'
Finished in 8.95 seconds
84 examples, 2 failures
Failed examples:
rspec ./spec/requests/user_pages_spec.rb:45 # User_pages delete links as an admin user
rspec ./spec/requests/user_pages_spec.rb:46 # User_pages delete links as an admin user should be able to delete another user
My files:
https://gist.github.com/ephunit/261670a9fbfe0f3ad471
Much apprecitated for any guidance.
Upvotes: 0
Views: 209
Reputation: 29389
The examples that are failing were introduced in Listing 9.42, not Listing 9.40. They should have been inserted as part of the "index"
example, but you have them inserted as part of the top level "User Pages"
example.
As a result, the first user is created as an admin user rather than as a regular user, which screws up your results.
This kind of problem is easier to avoid/detect if you faithfully stick to Ruby's indentation conventions of two spaces per indent.
Upvotes: 2