我使用以下方法安装了 Mocha 0.9.7 Rails 插件:
$ script/plugin install git://github.com/floehopper/mocha.git
(只需按照http://mocha.rubyforge.org/中的说明进行操作)
然后,我在功能测试中定义了以下设置
def setup
@controller.expects(:logged_in?).returns(true)
@controller.expects(:admin_user?).returns(true)
end
运行测试会生成 ff。错误:
NameError: uninitialized constant Mocha::Mockery::ImpersonatingName
/test/functional/xxxx_controller_test.rb:x:in `setup'
在此之前,我看到了ff。测试日志顶部的错误:
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/test_case.rb:12: warning: already initialized constant Mocha
这让我相信我在 Ruby 或 Rails 路径中的某个地方有一个旧版本的 Mocha。问题是我找不到。
我的猜测正确吗?如果是这样,这个旧版本的摩卡在哪里?或者,我怎样才能知道它在哪里?