I have the following request rspec test:
describe "CRUD" do
it "should list users" do
10.times do
FactoryGirl.create(:user)
end
visit users_path
page.should have_selector('table tr', :count => 10)
end
end
The problem is that it always gives this error:
1) Users CRUD should list users
Failure/Error: page.should have_selector('table tr', :count => 10)
expected css "table tr" to return something
Any ideas of why this is happening? It looks very similar to the test in rspec manual.
Thanks.
According to the capybara docs, supplying count checks for that exact number. You’re checking for 10 rows, but you have 12.
http://rubydoc.info/github/jnicklas/capybara/master/Capybara/Node/Matchers#has_selector%3F-instance_method