为什么我的Rails应用程序找不到与它一起打包的宝石?

时间:2009-12-02 23:23:17

标签: ruby-on-rails rubygems rspec cucumber

我有一个使用Cucumber和RSpec的Rails应用程序。我们将宝石存储在供应商/宝石下,并尝试在CI服务器中构建应用程序(运行测试)。

当我尝试运行测试时,我收到以下错误:

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

当我运行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)

空白[]是否意味着缺少宝石?

config / environments / test.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'))

所以一切看起来都是有序的,但它仍然拒绝运行。

我错过了一些明显的东西吗?

1 个答案:

答案 0 :(得分:4)

cucumber目录中的rspecrspec-railsvendor/gems已冻结(解包),但您缺少cucumber的依赖关系rspec-rails。正如对问题的评论所说,[]表示缺少。

我会重新开始:

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

然后在本地安装gems:

gem install rspec rspec-rails cucumber

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

最后,如果需要,请将其打包到您的vendor/gems目录中:

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

或者:

RAILS_ENV=test rake gems:unpack:dependencies

只需将测试环境的所有内容解压缩到vendor/gems。这会解压您当前在本地安装但未冻结到应用程序中的nokogiri gem。