From 6e64400e9ea5e74cc72b0b025d7c53a32cd67962 Mon Sep 17 00:00:00 2001 From: Enrico Stano Date: Mon, 28 May 2018 15:21:05 +0200 Subject: [PATCH] Better background job expectation --- spec/services/persister/post_persister_spec.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/spec/services/persister/post_persister_spec.rb b/spec/services/persister/post_persister_spec.rb index 3f969fa9c..16058b963 100644 --- a/spec/services/persister/post_persister_spec.rb +++ b/spec/services/persister/post_persister_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Persister::PostPersister do +RSpec.describe Persister::PostPersister do let(:organization) { Fabricate(:organization) } let(:user) { Fabricate(:user) } let(:category) { Fabricate(:category) } @@ -32,11 +32,12 @@ context 'background job' do before do allow(::Event).to receive(:create!).and_return(event) - persister.save end it 'enqueues a CreatePushNotificationsJob background job' do - expect(CreatePushNotificationsJob).to have_been_enqueued.with(event_id: 27) + expect { + persister.save + }.to enqueue_job(CreatePushNotificationsJob).with(event_id: 27) end end end @@ -57,11 +58,12 @@ context 'background job' do before do allow(::Event).to receive(:create!).and_return(event) - persister.update_attributes(title: 'New title') end it 'enqueues a CreatePushNotificationsJob background job' do - expect(CreatePushNotificationsJob).to have_been_enqueued.with(event_id: 27) + expect { + persister.update_attributes(title: 'New title') + }.to enqueue_job(CreatePushNotificationsJob).with(event_id: 27) end end end