Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expected css "title" with text in capybara

Tags:

rspec

capybara

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
like image 951
vajapravin Avatar asked Apr 22 '12 15:04

vajapravin


1 Answers

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")
like image 178
rbnewb Avatar answered Nov 08 '22 14:11

rbnewb