[rspec-users] undefined method `has_selector?' for "":String

Toni Tuominen tjtuom at utu.fi
Mon Sep 20 06:04:45 EDT 2010


You should use this gem: http://github.com/grimen/rspec_tag_matchers

- Toni

On Sun, Sep 19, 2010 at 9:16 PM, David Chelimsky <dchelimsky at gmail.com> wrote:
> On Sep 19, 2010, at 12:44 PM, Lord Raiden wrote:
>
>> I'm running rails 3.0.0 on ruby 1.9.2p0.
>>
>> I've rspec beta 22 with Capybara 0.3.9. NO WEBRAT.
>>
>> I'm unable to use 'rendered.should have_selector('a') in my view specs.
>>
>>  1) home/_menu.erb should add a link to home first
>>     Failure/Error: rendered.should have_selector('a', 'Home')
>>     undefined method `has_selector?' for "":String
>>
>> I read in this forum that rspec beta 20 and above should pick Capybara
>> automatically if its included in Gemfile.
>>
>> In my gem file I've this:
>>
>> group :development, :test do
>>  gem 'database_cleaner'
>>  gem 'cucumber-rails'
>>  gem 'cucumber'
>>  gem 'rspec-rails', ">= 2.0.0.beta.19"
>>  gem 'capybara'
>>  gem 'spork'
>>  gem 'launchy'    # So you can do Then show me the page
>>  gem 'machinist', '>= 2.0.0.beta1'
>> end
>>
>> Can anyone please point out what am I missing here? Thanks in advance.
>
> Two issues:
>
> 1. Capybara matchers do not support arbitrary strings, so they do not work in view specs
> 2. Even if they did, the capybara matcher would be has_css, not has_selector
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list