I am using capybara in place of webrat in rails. I have installed capybara and use gem 'capybara' in Gemfile. when I use
page.should have_selector("title", :text => "anything title")
it's give an error
Failure/Error: page.should have_selector("title", :text => "anything title")
expected css "title" with text "anything title" to return something
test file is as below:
require 'spec_helper'
describe "Test pages" do
describe "Home page" do
it "should have the content 'Demo App'" do
visit '/test_pages/home'
page.should have_selector("title", :text => "anything title")
end
end
end
Not sure which version of gems you are using but I ran into a similar instance where using :text failed but when I used :content it passed the test. I'm using rails 3.2.3, rspec-rails 2.9.0, capybara 1.1.2 and therubyracer gems on Ubuntu Lucid Lynx.
Try replacing
page.should have_selector("title", :text => "anything title")
with
page.should have_selector("title", :content => "anything title")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With