【发布时间】:2014-08-11 21:19:06
【问题描述】:
下面是我的model 方法,它接受一个id 和auth 令牌。
Project.find( id: '22', authorization: auth)
下面是我的测试。
require 'project'
RSpec.describe Project do
it 'finds an project' do
project = class_double("project")
expect(project).to receive(:find).with()
// How can i send id and authorization inside with
end
end
如何通过在with 中传递id 和authorization 来生成this test pass?。
【问题讨论】:
-
当您将 id 和 auth 都传递给 with 时,您看到了什么错误?如果您在某处定义
id和auth,您应该可以在代码中使用:expect(project).to receive(:find).with(id, auth)。
标签: ruby-on-rails ruby ruby-on-rails-4 rspec rspec3