2012-05-28 6 views
6

私は既存のrspecsとキュウリの機能がすべて正常に動作しています。キュウリはすごくうまくいきましたが、sporkは "初期化されていない定数Cucumber :: Rails"を与えています

私はいくつかの再実行速度を上げるために、spork(実際にはspork-rails)をインストールしています。

私はspsporkでうまく動作しているrspecを持っています。

私はenv.rbを命令ごとに変更しましたが(を実行しようとするとuninitialized constant Cucumber::Railsと表示されます)

方法によって

のRails 3.2の任意のアイデア?

は、ここに私の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 

答えて

4

私はこれを修正するために何をしたかダウンを指摘今後の参考のために。最終的には、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 
関連する問題