ruby – `require’:无法加载这样的文件 – mongo(LoadError)

`require’:无法加载这样的文件 – mongo(LoadError)

不知道为什么我收到这个错误.我使用的所有其他宝石都可以正常工作.我的rspec测试的顶部看起来像:

require 'rubygems'
require 'spec_helper.rb'
require 'base64'
require 'json'
require 'bigdecimal'
require 'mysql2'
require 'mongo'

‘mongo’然而在irb中工作:

irb => require 'mongo'
true

当我在脚本中使用它时它也可以工作.只是不在我的rspec测试中.我的文件结构如下:
automation / test / spec / lib / test_spec.rb尽管如此,我从哪里开始测试并不重要.我也在使用RVM,但就像我之前所说的所有其他宝石都在工作所以我不相信它是一个路径问题.

对于版本控制比较,这里是我的宝石列表的副本:

bson (1.9.2)
bson_ext (1.9.2)
mongo (1.9.2)
rspec (2.14.1)
rspec-core (2.14.4)
rspec-expectations (2.14.0)
rspec-mocks (2.14.4, 2.14.1)

最佳答案 所以进一步研究’捆绑/设置’感谢Matt我发现在我的Gemfile中添加gem’mongo’似乎解决了这个问题.

点赞