我有以下示例:
it 'receives message' do
expect(Foo).to receive(:bar).with(baz)
OtherClass.send(baz)
end
class OtherClass
def self.send(baz)
Foo.bar(1) # this first one is the problem
Foo.bar(baz)
end
end
class Foo
def self.bar(whatever)
puts whatever + " was received"
end
end
这是错误:
Failure/Error: Foo received :bar with unexpected arguments
答案 0 :(得分:0)
How to say "should_receive" more times in RSpec
你也可以使用“expect(Foo).to receive(:bar).twice”。