Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cucumber rails -

I have created a new rails 3.2 app and my cucumber specs are returning this error -

undefined method `path_to' for #<Cucumber::Rails::World:

When running:

When /^(?:|I )go to (.+)$/ do |page_name|
  visit path_to(page_name)
end

My bundler looks like this:

  • capybara (1.1.2)
  • cucumber (1.1.4)
  • cucumber-rails (1.2.1)
  • database_cleaner (0.7.0)
  • factory_girl (2.2.0)
  • factory_girl_rails (1.3.0)
  • gherkin (2.7.6)
  • guard (0.8.8)
  • guard-cucumber (0.7.5)
  • guard-rspec (0.5.11)
  • rails (3.2.1)
  • rspec (2.8.0)
  • rspec-core (2.8.0)
  • rspec-expectations (2.8.0)
  • rspec-mocks (2.8.0)
  • rspec-rails (2.8.1)
  • selenium-webdriver (2.18.0)
  • xpath (0.1.4)

Any idea why ? I thought it was capybara but it is uptodate.

like image 290
Alex Avatar asked Mar 15 '26 23:03

Alex


2 Answers

In feature/support/paths.rb

module NavigationHelpers
 def path_to(page_name)
   case page_name
   when /home page/
    root_path
   else
    begin
     page_name =~ /the (.*) page/
     path_components = $1.split(/\s+/)
     self.send(path_components.push('path').join('_').to_sym)
    rescue Object => e
     raise "can't find mapping from \"#{page_name}\" to a path. \n" + "Now, go and add a mapping in #{__FILE__}" 
    end
   end
 end
end

write above code into your paths.rb file

like image 62
Dipak Panchal Avatar answered Mar 17 '26 12:03

Dipak Panchal


If you want to use path_to method from cucumber-rails-training-wheels gem you should add this file to your support folder: https://github.com/cucumber/cucumber-rails-training-wheels/blob/master/lib/generators/cucumber_rails_training_wheels/install/templates/support/paths.rb

like image 27
Vasiliy Ermolovich Avatar answered Mar 17 '26 14:03

Vasiliy Ermolovich