rspec:"没有要加载的文件 - rspec / mocks"

时间:2012-09-06 02:47:28

标签: rspec mocking rspec-mocks

我正在尝试在一些非常简单的Ruby上运行测试。我的linux机器上安装了ruby和rails。我也安装了rspec。我的宝石列表是:

LOCAL GEMS

actionmailer (3.2.8)
actionpack (3.2.8)
activemodel (3.2.8)
activerecord (3.2.8)
activeresource (3.2.8)
activesupport (3.2.8)
arel (3.0.2)
builder (3.0.0)
bundler (1.2.0, 1.1.5)
diff-lcs (1.1.3)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.1, 0.6.0)
journey (1.0.4)
json (1.7.5)
mail (2.4.4)
mime-types (1.19)
multi_json (1.3.6)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.8)
railties (3.2.8)
rake (0.9.2.2)
rdoc (3.12)
rspec (2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.2)
rspec-mocks (2.11.2)
rubygems-bundler (1.0.7)
rvm (1.11.3.5)
sprockets (2.4.5, 2.1.3)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)

但是当我跑步时

 rspec my_test_file.rb

我收到以下错误:

/usr/lib/ruby/vendor_ruby/rspec/core/mocking/with_rspec.rb:1:in `require': no such file to load -- rspec/mocks (LoadError)
from /usr/lib/ruby/vendor_ruby/rspec/core/mocking/with_rspec.rb:1
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:116:in `require'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:116:in `mock_framework'
from /usr/lib/ruby/vendor_ruby/rspec/core/configuration.rb:376:in `configure_mock_framework'
from /usr/lib/ruby/vendor_ruby/rspec/core/command_line.rb:19:in `run'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:55:in `run_in_process'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:46:in `run'
from /usr/lib/ruby/vendor_ruby/rspec/core/runner.rb:10:in `autorun'
from /usr/bin/rspec:4

这似乎特定于rspec / mocks(与SE上发布的其他“没有这样的文件加载”ruby错误不同)。那我错过了什么?

1 个答案:

答案 0 :(得分:1)

这根本不是一个rspec问题。我的机器只是不知道在哪里寻找宝石文件。我必须按如下方式更新我的.bashrc文件:

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
[[ -s "/home/jason/.rvm/scripts/rvm" ]] && . "/home/jason/.rvm/scripts/rvm" # Load RVM function

现在一切正常。