I've got existing rspecs and cucumber features all running fine.
I'm installing spork (spork-rails in fact) to give me some re-run speed up.
I've got rspec running fine with spork.
I've just modified the env.rb as per instructions (very similar to the mods to spec_helper.rb), but I get uninitialized constant Cucumber::Rails when I try to run bundle exec cucubmer --drb.
Rails 3.2 by the way
Any ideas?
Here's my env.rb:
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
require 'spork/ext/ruby-debug'
if Spork.using_spork?
  Spork.prefork do
    require 'rails'
    require 'cucumber/rails'
    Capybara.default_selector = :css
    begin
      DatabaseCleaner.strategy = :transaction
    rescue NameError
      raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
    end    
  end
  Spork.each_run do
    # This code will be run each time you run your specs.
    require 'cucumber/rails'
    Cucumber::Rails::Database.javascript_strategy = :truncation
    ActionController::Base.allow_rescue = false
    module NavigationHelpers
      def path_to(page_name)
        case page_name
        when /the home page/
          root_path
        # Add more page name => path mappings here
        else
          if path = match_rails_path_for(page_name)
            path
          else
            raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
            "Now, go and add a mapping in features/support/paths.rb"
          end
        end
      end
      def match_rails_path_for(page_name)
        if page_name.match(/the (.*) page/)
          return send "#{$1.gsub(" ", "_")}_path" rescue nil
        end
      end
    end
    World(NavigationHelpers)  
  end
else
  #omitted
end
For future reference noting down what I did to fix this. In the end I think it was an odd symptom of having referenced cucumber-rails slightly wrongly in the Gemfile.
I was getting errors as well saying:
WARNING: Cucumber-rails required outside of env.rb. 
The rest of loading is being defered until env.rb is called. 
To avoid this warning, move 'gem cucumber-rails' under only
group :test in your Gemfile 
Following the instructions in https://github.com/cucumber/cucumber/issues/249, I fixed this by adding require: false to my Gemfile as follows:
group :test do
  gem 'cucumber-rails', require:false
  #....
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With