当我尝试存根/模拟不存在的方法时,有没有一种方法可以配置RSpec引发错误。
所以,如果我有课
class A
def foo
end
end
我写类似:
describe A do
describe '#foo' do
it 'foos' do
expect(subject).to receive(foo2)
# fire
subject.foo
end
end
end
那么RSpec将在第一行失败
expect(subject....
通过告诉我这:foo2
不是subject
响应的消息。
该功能在rspec-fire gem中引入,并且最近已移植到RSpec 3(当前为beta)中,如该github问题中所述。它记录在https://relishapp.com/rspec/rspec-mocks/docs/verifying-doubles
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句