【发布时间】:2015-05-27 10:00:49
【问题描述】:
我希望能够使用 rspec 测试使用特定块调用的特定 gem:
代码如下所示
SomeGem.configure do |config|
config.username = "hello"
config.password = "world"
end
我写的规范是这样的:
it 'sets valid gem configuration' do
credentials = lambda do |config|
config.username = "hello"
config.password = "world"
end
expect(SomeGem).to receive(:configure).with(credentials)
end
我得到的错误:
Failure/Error: expect(SomeGem).to receive(:configure).with(credentials)
Wrong number of arguments. Expected 0, got 1.
关于我应该如何测试这个有什么想法吗?
【问题讨论】:
标签: ruby-on-rails ruby rspec mocking