黄瓜无法加载这样的文件 - rails(LoadError)

时间:2013-07-27 18:28:07

标签: cucumber ruby-on-rails-4

我已经在https://github.com/cucumber/cucumber-rails#installation

之后将cucumber-rails gem安装到新的Rails 4应用程序中

但是当我尝试运行它时会发生错误:

biske@biske:~/bla$ cucumber

cannot load such file -- rails (LoadError)
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'require'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'rescue in require'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:35:in 'require'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-rails-1.3.1/lib/cucumber/rails.rb:3:in '<top (required)'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'require'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:60:in 'rescue in require'
/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:35:in 'require' /home/biske/bla/features/support/env.rb:7:in '<top (required)'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/rb_support/rb_language.rb:122:in 'load'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/rb_support/rb_language.rb:122:in 'load_code_file'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:180:in'load_file'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:83:in 'block in load_files!'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:82:in 'each'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime/support_code.rb:82:in 'load_files!'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:183:in 'load_step_definitions'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/runtime.rb:42:in 'run!'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/lib/cucumber/cli/main.rb:47:in 'execute!'
/usr/lib/ruby/gems/1.9.1/gems/cucumber-1.3.4/bin/cucumber:13:in '<top (required)' /usr/bin/cucumber:23:in 'load' /usr/bin/cucumber:23:in '<main'

这个错误抱怨来自features / support / env.rb文件的第7行,即:

require 'cucumber/rails'

这里有什么问题?

3 个答案:

答案 0 :(得分:1)

在将cucumber-rails版本升级到1.3.15之后,我遇到了这个问题。

首先重新生成黄瓜配置(特别是如果你最近更新了一些宝石):

rails g cucumber:install

如果没有帮助尝试使用命令在捆绑器中运行黄瓜:

bundle exec cucumber

或更方便且技术上相同的命令(在我的情况下在rails 4.1.1上工作):

rake cucumber

详细了解“bundle exec”命令前缀:Use bundle exec rake or just rake?

答案 1 :(得分:0)

cd进入features文件夹,然后尝试运行cucumber your_feature_name.feature

答案 2 :(得分:0)

在我的情况下,问题是我在功能/支持中使用的文件env.rb需要一个它不应该存在的文件,或者不存在的文件。

因此,请检查features / support / env.rb,尽可能多地编辑,看看是否有帮助。