In the following case I don't have access to created_object until it's
created, but I expect that somewhere inside SomeCreateService.create the
method SomeProcessService.create would be called with the created object:
it "does something" do
expect(SomeProcessService).to receive(:process) do |object|
expect(object).to eq(created_object)
end
created_object = SomeCreateService.create!
end
This works, though:
it "does something" do
called_with_object = nil
expect(SomeProcessService).to receive(:process) do |object|
called_with_object = object
end
created_object = SomeCreateService.create!
expect(created_object).to eq(called_with_object)
end
Is there a nicer way? (Like delaying all the receive expectations to the
end of the example)
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/fe724d55-b3a6-439d-9b59-f8cc7bb1f43c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.