Tim*_*ins 6 ruby-on-rails cucumber spork
我现有的rspecs和黄瓜功能都运行良好.
我正在安装spork(事实上是spork-rails)给我一些重新加速的速度.
我的sppec运行得很好.
我刚刚按照说明修改了env.rb(非常类似于spec_helper.rb的mod),但是uninitialized constant Cucumber::Rails
当我尝试运行时,我得到了bundle exec cucubmer --drb
.
顺便说一下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
Run Code Online (Sandbox Code Playgroud)
记下我为解决此问题所做的工作,以供将来参考。最后,我认为这是在 Gemfile 中稍微错误地引用了 Cucumber-rails 的一个奇怪症状。
我也遇到错误:
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
Run Code Online (Sandbox Code Playgroud)
按照https://github.com/cucumber/cucumber/issues/249中的说明,我通过将 require: false 添加到我的 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
Run Code Online (Sandbox Code Playgroud)