为什么我的Rails应用不能找到与之配套的精华呢?

时间:2021-02-05 20:41:17

I've got a Rails app making use of Cucumber and RSpec. We are storing the gems under vendor/gems and trying to get the app building (running tests) in a CI server.

我有一个使用Cucumber和RSpec的Rails应用。我们正在供应商/gems下存储gem,并试图在CI服务器中建立应用程序(运行测试)。

When I try to run our tests I'm getting the following error:

当我尝试运行我们的测试时,我得到了以下错误:

Missing these required gems:
  cucumber  >= 0.3.11
  rspec-rails  >= 1.2.6

When I run RAILS_ENV=test rake gems I get the following:

当我运行RAILS_ENV=test rake gems时,我得到以下内容:

 - [F] activerecord-oracle-adapter
    - [R] activerecord >= 1.15.5.7843
 - [F] thoughtbot-factory_girl = 1.2.0
 - [F] cucumber >= 0.3.11
    - [ ] term-ansicolor >= 1.0.3
    - [ ] treetop >= 1.2.6
    - [ ] diff-lcs >= 1.1.2
    - [I] builder >= 2.1.2
 - [F] webrat >= 0.4.4
    - [I] nokogiri >= 1.2.0
 - [F] rspec >= 1.2.6
 - [F] rspec-rails >= 1.2.6
    - [F] rspec >= 1.2.7
    - [ ] rack >= 0.4.0
 - [F] thoughtbot-shoulda >= 2.10.2

I = Installed
F = Frozen
R = Framework (loaded before rails starts)

Do the blank empty [ ]'s mean the gem is missing?

空的[]表示宝石丢失了吗?

config/environments/test.rb contains the following:

配置/环境/测试。rb包含以下:

config.gem "cucumber",           :lib => false,          :version => ">=0.3.11" unless File.direct
ory?(File.join(Rails.root, 'vendor/plugins/cucumber'))
config.gem "webrat",             :lib => false,          :version => ">=0.4.4"  unless File.direct
ory?(File.join(Rails.root, 'vendor/plugins/webrat'))
config.gem "rspec",              :lib => false,          :version => ">=1.2.6"  unless File.direct
ory?(File.join(Rails.root, 'vendor/plugins/rspec'))
config.gem "rspec-rails",        :lib => "spec/rails",   :version => ">=1.2.6"  unless File.direct
ory?(File.join(Rails.root, 'vendor/plugins/rspec-rails'))
config.gem "thoughtbot-shoulda", :lib => false,          :version => ">=2.10.2" unless File.direct
ory?(File.join(Rails.root, 'vendor/plugins/shoulda'))

So everything looks in order, but it still refuses to run.

所以一切看起来都很正常,但它仍然拒绝运行。

Am I missing something obvious?

我是不是漏掉了什么明显的东西?

1 个解决方案

#1


4  

It looks like you have cucumber, rspec, and rspec-rails frozen (unpacked) in your vendor/gems directory but you are missing dependencies for cucumber and rspec-rails. As the comment on the question says, [] indicates that is missing.

看起来您在供应商/gems目录中有cucumber、rspec和rspec-rails冻结(unpack),但是您缺少cucumber和rspec-rails的依赖关系。正如对这个问题的评论所说,[]表明这个问题没有得到解决。

I would start over:

我想重新开始:

rm -rf vendor/gems/cucumber
rm -rf vendor/gems/rspec-rails
rm -rf vendor/gems/rspec

Then install the gems locally:

然后在本地安装gem:

gem install rspec rspec-rails cucumber

At this point you should be able to test the app successfully.

此时,您应该能够成功地测试应用程序。

Finally, unpack then into your vendor/gems dir if desired:

最后,如果需要,打开您的供应商/gem目录:

RAILS_ENV=test rake gems:unpack:dependencies GEM=rspec-rails
RAILS_ENV=test rake gems:unpack:dependencies GEM=cucumber

or alternatively:

或者:

RAILS_ENV=test rake gems:unpack:dependencies

to just unpack everything for the test environment into vendor/gems. This would unpack the nokogiri gem you currently have installed locally but not frozen into the app.

将测试环境中的所有东西分解为供应商/gems。这将打开你目前在本地安装的nokogiri gem,但不会冻结到应用程序中。

#1


4  

It looks like you have cucumber, rspec, and rspec-rails frozen (unpacked) in your vendor/gems directory but you are missing dependencies for cucumber and rspec-rails. As the comment on the question says, [] indicates that is missing.

看起来您在供应商/gems目录中有cucumber、rspec和rspec-rails冻结(unpack),但是您缺少cucumber和rspec-rails的依赖关系。正如对这个问题的评论所说,[]表明这个问题没有得到解决。

I would start over:

我想重新开始:

rm -rf vendor/gems/cucumber
rm -rf vendor/gems/rspec-rails
rm -rf vendor/gems/rspec

Then install the gems locally:

然后在本地安装gem:

gem install rspec rspec-rails cucumber

At this point you should be able to test the app successfully.

此时,您应该能够成功地测试应用程序。

Finally, unpack then into your vendor/gems dir if desired:

最后,如果需要,打开您的供应商/gem目录:

RAILS_ENV=test rake gems:unpack:dependencies GEM=rspec-rails
RAILS_ENV=test rake gems:unpack:dependencies GEM=cucumber

or alternatively:

或者:

RAILS_ENV=test rake gems:unpack:dependencies

to just unpack everything for the test environment into vendor/gems. This would unpack the nokogiri gem you currently have installed locally but not frozen into the app.

将测试环境中的所有东西分解为供应商/gems。这将打开你目前在本地安装的nokogiri gem,但不会冻结到应用程序中。