Prefer `expect_next_instance_of` over `expect_any_instance_of`

This commit is contained in:
Lin Jen-Shin 2018-06-25 20:28:49 +08:00
parent 901159bbae
commit f012b32bd1
1 changed files with 6 additions and 4 deletions

View File

@ -5,15 +5,17 @@ describe DeleteUserWorker do
let!(:current_user) { create(:user) }
it "calls the DeleteUserWorker with the params it was given" do
expect_any_instance_of(Users::DestroyService).to receive(:execute)
.with(user, {})
expect_next_instance_of(Users::DestroyService) do |service|
expect(service).to receive(:execute).with(user, {})
end
described_class.new.perform(current_user.id, user.id)
end
it "uses symbolized keys" do
expect_any_instance_of(Users::DestroyService).to receive(:execute)
.with(user, test: "test")
expect_next_instance_of(Users::DestroyService) do |service|
expect(service).to receive(:execute).with(user, test: "test")
end
described_class.new.perform(current_user.id, user.id, "test" => "test")
end