【问题标题】:rspec error - no such file to load -- rspec/mocks (LoadError)rspec 错误 - 没有要加载的文件 -- rspec/mocks (LoadError)
【发布时间】:2012-05-02 03:22:34
【问题描述】:

我正在学习 rspec。我有下面的简单示例。 为什么我会得到

/usr/lib/ruby/vendor_ruby/rspec/core/mocking/
with_rspec.rb:1:in `require': no such file to load -- rspec/mocks (LoadError)

describe "It should return the parameter that was passed in" do
  it "should return 20 when 20 is passed in" do
    a = fb(20)
    a.should == 20
  end
  it "should return 30 when 30 is passed in" do
    a = fb(30)
    a.should == 30
  end
end

代码:

def fb(n)
  n
end

我做了sudo apt-get install ruby-rspec-core 我需要另一个库吗? 为什么会有关于模拟的消息?看不到给出的代码如何需要它们

起初gem install rpsec 似乎有帮助,但现在我又收到了消息。

【问题讨论】:

    标签: ruby rspec rspec-mocks


    【解决方案1】:

    错误消息说您应该安装 rspec-mocks。
    请尝试通过以下命令安装。

    gem install rspec-mocks
    


    通常,只需键入以下命令。

    gem install rspec
    

    RubyGems 解决关于库的依赖关系,
    所以 RubyGems 会同时安装 rspec 和 rspec-mocks。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-13
      • 2011-07-25
      相关资源
      最近更新 更多