2012-05-28 4 views
6

나는 잘 실행중인 기존 rspecs과 오이 기능을 가지고있어.오이,하지만 spork없이 잘 작동 spork 나에게주는 "초기화되지 않은 상수 오이 : : 레일"

다시 실행 속도를 높이기 위해 실제로 spork (spork-rails)을 설치하고 있습니다.

spsp와 함께 잘 실행되는 rspec이 있습니다.

지침에 따라 env.rb를 수정했습니다 (spec_helper.rb의 개조와 매우 유사 함). bundle exec cucubmer --drb을 실행할 때 uninitialized constant Cucumber::Rails이 표시됩니다.

방법

어떤 아이디어로

레일 3.2 ?

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 

답변

4

나중에 참조 할 수 있도록 내가이 문제를 해결하기 위해 무엇을했는지 아래로 지적를 들어

여기 내 env.rb입니다. 결국 나는 Gemfile에서 오이 레일을 약간 잘못 참조한 것은 이상한 증상이라고 생각합니다. 내가 말을뿐만 아니라 오류를 얻고 있었다

:

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 

https://github.com/cucumber/cucumber/issues/249의 지침에 따라, 나는 추가하여이 고정이 필요합니다 내 Gemfile에 허위 다음과 같이

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