Below is my model
method which accepts an id and auth
token.
Project.find( id: '22', authorization: auth)
Below is my test.
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
How can i make this test pass
by passing id
and authorization
inside the with
?.
Project.find(id: '22', authorization: auth)
is shorthand for: Project.find({id: '22', authorization: auth})
This means you're passing one parameter to 'find': a hash.
expect(project).to receive(:find).with({id: the_id, authorization: the_auth})
You can omit the curly braces if you wish.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.