6
我有一個測試情況是這樣的:方法instance_double :: ExampleMethods
describe WorkCardsController do
it "something" do
work_card = instance_double(WorkCard, {:started?=>true})
#some more code
end
end
當我運行RSpec的,我得到一個錯誤:
undefined method 'instance_double' for #<Rspec::Core::ExampleGroup::Nested_1::Nested_8::Nested_3:0x007f0788b98778>
根據http://rubydoc.info/github/rspec/rspec-mocks/RSpec/Mocks/ExampleMethods這方法存在。於是,我就直接訪問它:
describe WorkCardsController do
it "something" do
work_card = RSpec::Mocks::ExampleMethods::instance_double(WorkCard, {:started?=>true})
#some more code
end
end
然後我得到了一個非常驚人的錯誤:
undefined method 'instance_double' for Rspec::Mocks::ExampleMEthods:Module
這違背了我上面鏈接的文檔。
我錯過了什麼?
確實有rspec3?這一刻的寶石版本是2.14,因此如果你沒有通過github安裝它,這是正常的,方法不存在。 – Iazel