jnicklas / turnip

Gherkin extension for RSpec
972 stars 112 forks source link

turnip/capybara problems #49

Closed gavinlaking closed 12 years ago

gavinlaking commented 12 years ago

I'm having a bit of trouble running my turnip features. Specifically, I'm getting the following error:

1) Searching Searching by term, no results found
  Failure/Error: Turnip::ScenarioRunner.new(self).load(Turnip::ScenarioContext.new(feature, scenario)).run
  NoMethodError:
    undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1:0x007fa9326da7f8>
  # spec/step_definitions/customers/searches_steps.rb:2:in `block in <top (required)>'

My spec_helper:

require File.expand_path("../spec/dummy/config/environment", __FILE__)

require "turnip/capybara"

RSpec.configure do |config|
  config.treat_symbols_as_metadata_keys_with_true_values = true
  config.run_all_when_everything_filtered = true
  config.filter_run :focus

  Turnip::Config.step_dirs = 'spec/step_definitions'
  Turnip::StepLoader.load_steps
end

My spec/features/customers/search.feature:

Scenario: Searching by term, no results found
  When I visit the customer search page
  And I search for "albion heights"
  Then I should see "No results found"

And finally my spec/step_definitions/customers/searches_steps.rb:

step "I visit the customer search page" do
  visit "/searches" # temp path
end

Any ideas? I'm sure I'm missing a configuration line!

Cheers

Gav

jnicklas commented 12 years ago

That's quite strange. Can you take a peek at example.metadata inside your step and see what that gives you, specifically, what is :type set to, it should be :request.

gavinlaking commented 12 years ago

:type is set to :request. I added the require "rspec/rails" above the require "turnip/capybara" line and now things have started working. I've got a funny feeling I had a mangled configuration Jonas, my apologies for that.

tammersaleh commented 11 years ago

Interesting... would it be possible to detect when someone is attempting to use the rspec/rails stuff inside turnip without it being required? Would give us a chance to print out a helpful error message.

yeehaa123 commented 11 years ago

I have the same problem. Solution does not work for me unfortunately… I am using Capybara 2.0. Could that be the problem?

jnicklas commented 11 years ago

Yes, we'll create a release which is compatible with Capybara 2.0 within the next few days.