Avoid using expect_any_instance_of

We can't use it for prepended module, so use
`and_wrap_original` to wrap around the instance.
This commit is contained in:
Lin Jen-Shin 2018-05-23 18:06:06 +08:00
parent acdb7435da
commit ec31fa260b
1 changed files with 7 additions and 2 deletions

View File

@ -18,8 +18,13 @@ describe UpdateMergeRequestsWorker do
end
it 'executes MergeRequests::RefreshService with expected values' do
expect(MergeRequests::RefreshService).to receive(:new).with(project, user).and_call_original
expect_any_instance_of(MergeRequests::RefreshService).to receive(:execute).with(oldrev, newrev, ref)
expect(MergeRequests::RefreshService).to receive(:new)
.with(project, user).and_wrap_original do |method, *args|
method.call(*args).tap do |refresh_service|
expect(refresh_service)
.to receive(:execute).with(oldrev, newrev, ref)
end
end
perform
end