2012-05-28 14 views
6

Ho le funzioni rspecs e cetriolo già funzionanti.cetriolo che lavora bene senza spork, ma spork mi dà "Cetriolo costante non inizializzato :: Rails"

Sto installando spork (rail in realtà) per darmi un po 'di riaccelerazione.

Ho rspec che funziona bene con spork.

Ho appena modificato env.rb come da istruzioni (molto simile alle mod a spec_helper.rb), ma ottengo uninitialized constant Cucumber::Rails quando provo a eseguire bundle exec cucubmer --drb.

Rails 3.2 a proposito

Tutte le idee?

Ecco la mia 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 

risposta

4

Per riferimento futuro annotando quello che ho fatto per risolvere questo problema. Alla fine, penso che fosse uno strano sintomo di aver fatto riferimento a rotaie di cetrioli in modo leggermente errato nel Gemfile.

mi stavo errori così dicendo:

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 

Seguendo le istruzioni riportate nella https://github.com/cucumber/cucumber/issues/249, ho risolto questo con l'aggiunta richiedono: false al mio Gemfile come segue:

group :test do 
    gem 'cucumber-rails', require:false 
    #.... 
end 
Problemi correlati