have_selector :content doesn't work with capybara #478

Closed
boringusername99 opened this Issue Jan 9, 2012 · 5 comments

Comments

Projects
None yet
4 participants
Contributor

boringusername99 commented Jan 9, 2012

I'm finding that have_selector doesn't behave as described in the documentation (http://rubydoc.info/gems/rspec-rails/frames). I'm using rspec with capybara, and while have_selector correctly fails when provided tags are missing, it doesn't fail for any content passed as a secondary requirement.

For example:
it "should load acceptance page after login" do
visit "/"
u = Factory.create(:user)
fill_in "user[email]", :with => 'jason1@test.com'
fill_in "user[password]", :with => 'lada123'
click_button "Sign in"

  page.should have_selector("p.notice", :content => "Signed in") # this shouldn't and doesn't fail
  page.should have_content("XYZABC") # this fails
  page.should have_selector("p.notice", :content => "XYZABC") # this should but doesn't fail

Note: I'm using rails 3.1.1, rspec-rails 2.7.0, capybara 1.1.1, and I'm doing require 'capybara/rspec' in my spec_helper.

Contributor

justinko commented Jan 9, 2012

This is a Capybara issue, as the matchers (have_selector) are provided by Capybara. Have you tried save_and_open_page to see it for yourself?

Going to close this, please post this to Capybara. Thanks.

@justinko justinko closed this Jan 9, 2012

Contributor

boringusername99 commented Jan 9, 2012

Thanks, and sorry for filing in the wrong place. I will post in Capybara. FYI, no matter what I enter for content, the test passes - just as long as the selector exists. Thanks for the suggestion; save_and_open_page confirms the same.

I'm struggling with capybara as well
But for this issue, I think that have_selector does not support the option :content, but uses the option :text. I.e.,

page.should have_selector("p.notice", :text => "XYZABC") 
Contributor

boringusername99 commented Feb 24, 2012

yes, thanks. I discovered this as well. Ultimately, it turned out to be partly an issue with the rspec documentation that has been corrected to reflect that :text is the right option to use.

We just hit this bug as well. Any possibility to simply support :content as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment