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'

这里可能有什么问题?

4

3 回答 3

1

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

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

rails g cucumber:install

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

bundle exec cucumber

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

rake cucumber

了解有关“bundle exec”命令前缀的更多信息:使用 bundle exec rake 还是仅 rake?

于 2014-05-12T19:12:24.123 回答
1

就我而言,问题是我在功能/支持中拥有的文件 env.rb 需要一个它不应该有的文件,或者该文件不存在。

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

于 2015-10-09T16:57:05.543 回答
0

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

于 2013-08-05T03:52:36.437 回答