RoR - Failure/Error: response.should have.selector, Integration Test Failure

784 Views Asked by At

Hi I'm pretty new in RoR, and I'm trying to follow Michael Hartl's tutorial where I got problem during integration test.

I tried the solution given here, Why is Rspec saying "Failure/Error: Unable to find matching line from backtrace"?. but still I get errors.

So when I run $ rspec spec/ , it shows,

1) LayoutLinks should have a Home page at '/'
 Failure/Error: response.should have.selector('title', :content => "Home")
 ArgumentError:
   wrong number of arguments (0 for 1)
 # ./spec/requests/layout_links_spec.rb:7:in `block (2 levels) in <top (required)>'

And here's my gem list:

webrat (0.7.1)
xpath (0.1.4)
ZenTest (4.6.2)
rspec (2.8.0, 2.0.1)
rspec-core (2.8.0, 2.0.1)
rspec-expectations (2.8.0, 2.0.1)
rspec-mocks (2.8.0, 2.0.1)
rspec-rails (2.8.1, 2.8.0, 2.0.1, 2.0.0.beta.18)
rubyzip (0.9.5)
sass (3.1.12)
sass-rails (3.2.3, 3.1.5)
capybara (1.1.2)
childprocess (0.3.0)
coffee-rails (3.2.1, 3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
cucumber (1.1.4)
cucumber-rails (1.2.1)
factory_girl (2.4.2)
factory_girl_rails (1.5.0)

And here's my gem file:

gem 'therubyracer'
gem 'sqlite3'

group :development do
gem 'rspec-rails'
end

group :test do
gem 'webrat', '0.7.1'
gem 'rspec'
end

Gems used only for assets and not required
in production environments by default.
group :assets do
gem 'sass-rails',   '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.0'

gem 'uglifier', '>= 1.0.3'
end

My guess is it's webrat/capybara problem but I have no idea how to solve this. Any help will be much appreciated. Thank you!

1

There are 1 best solutions below

3
On

Well i have same problem with title selector and capybara. This one code works well for me, try it:

within('head title') { page.should have_content "Home" }