0

I'm in the process of upgrading an old krufty application to Rails 3.1. The company has been using RSpec and Capybara for acceptance tests. We've got some acceptance tests under spec/acceptance that are failing with the following message:

Failure/Error: get @url
 NoMethodError:
   undefined method `get' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007feb7c0abf58>

Here's an example of one of the tests (from the top of the file):

require_relative 'acceptance_helper'                                                                                                                                                 

feature 'Catalog' do                                                                                                                                                                 
  before do                                                                                                                                                                          
    Settings.use_catalog_navigation = true                                                                                                                                           
  end                                                                                                                                                                                

  context 'with a Vendor' do                                                                                                                                                         
    before do                                                                                                                                                                        
      @vendor = create(:vendor, slug: 'abc')                                                                                                                                         
      @product = create(:product_with_variants, vendor: @vendor)                                                                                                                     

      @non_vendor_product = create(:product_with_variants)                                                                                                                           
      @invisible_product = create(:product_with_variants,                                                                                                                            
                                   vendor: @vendor,                                                                                                                                  
                                   visible: false)                                                                                                                                   
      @non_available_product = create(:product_with_variants,                                                                                                                        
                                       vendor: @vendor,                                                                                                                              
                                       available: false)                                                                                                                             

      @url = "/#{@vendor.slug}"                                                                                                                                                      
    end                                                                                                                                                                              

    it 'sets @vendor' do   # <- FIRST FAILING TEST                                                                                                                                                          
      get @url                                                                                                                                                                       
      assigns(:vendor).should == @vendor                                                                                                                                             
    end

    ...  

When consulting the oracle, I keep stumbling across issues mentioning the 'visit' method such as this: https://github.com/jnicklas/capybara/issues/814

I also keep coming across posts related to this article: http://alindeman.github.com/2012/11/11/rspec-rails-and-capybara-2.0-what-you-need-to-know.html

I'm not sure that I'm having the same issue. I can post my spec_helper.rb and acceptance_helper.rb if they will be of any use.

I guess it's worth noting that these specs passed before I updated rspec-rails and capybara.

My gut feeling is that perhaps rspec-rails is clobbering some of capybara's methods, or some of capybara's methods are simply no longer being loaded. Could that be the issue?

cmhobbs
  • 2,469
  • 3
  • 24
  • 30
  • I had a similar problem recently when upgrading from Rails 3.1.0 to 3.1.10. The answer (for me) was to downgrade my selenium-webdriver to 2.21.1 from 2.21.2. Give this a shot and hopefully it helps move you closer to solving your problem! – MrDanA Jan 10 '13 at 18:00
  • We weren't using selenium. It turns out the problem was that there were two test blocks in the Gemfile, which I believe was causing RSpec to be loaded after Capybara. I'd answer my own question, but I'm not 100% certain why having two test blocks was causing the issue. I'll need to track down the person responsible and ask why it was done that way. – cmhobbs Jan 10 '13 at 19:33

1 Answers1

0

Try and add config.include Capybara::DSL in spec_helper.rb, inside the config block. like so:

RSpec.configure do |config|
  config.include Capybara::DSL
egyamado
  • 1,111
  • 4
  • 23
  • 44