chourobin
chourobin

Reputation: 4124

Undefined local variable or method 'page' for Cucumber::Rails::World (NameError)

I'm running a basic feature by following RBates RailsCasts tutorial using Rspec 2.5.0 and Cucumber-rails 0.4.1 on a cygwin environment. I am at the step where I am testing "Then I should see"

For example:

Scenario: Stores List
    Given I have stores named Pizza, Breadsticks
    When I go to the list of stores
    **Then I should see "Pizza"**

Running cucumber features gives me the following error message:

Undefined local variable or method 'page' for Cucumber::Rails::World (NameError)

Then I should See is defined in the web_steps file as follows:

 if page.respond_to? :should
    page.should have_content(text)
  else
    assert page.has_content?(text)
  end

Any guidance would be appreciated!

Thank you!

Upvotes: 2

Views: 2532

Answers (2)

chourobin
chourobin

Reputation: 4124

Fixed the error. I had commented out:

Capybara.default_selector = :css because of a previous issue (See: https://github.com/aslakhellesoy/cucumber-rails/issues/120). Once i included the following:

require 'capybara/rails' require 'capybara/cucumber'

It fixed the capybara issue and the page method was available.

Thanks.

Upvotes: 1

snowBlind
snowBlind

Reputation: 975

I don't know much of RoR, and without seeing more code, it appears you haven't defined the variable 'page', or you defined it in an area that is outside the scope of where you're trying to use it.

Upvotes: 0

Related Questions