Skip to content

Commit

Permalink
Better background job expectation
Browse files Browse the repository at this point in the history
  • Loading branch information
enricostano committed May 29, 2018
1 parent 76d5f0f commit 6e64400
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions spec/services/persister/post_persister_spec.rb
Original file line number Diff line number Diff line change
@@ -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) }
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6e64400

Please # to comment.