Skip to content

Instantly share code, notes, and snippets.

@ejlangev
Last active August 29, 2015 13:58
Show Gist options
  • Save ejlangev/9937830 to your computer and use it in GitHub Desktop.
Save ejlangev/9937830 to your computer and use it in GitHub Desktop.
feature "Short Messaging" do
let(:member) { create(:member) }
let(:admin) { create(:admin) }
let(:message) {
GrouperShortMessager.custom_message(message, admin, "Hello, World!")
}
around do |example|
previous_value = Resque.inline
Resque.inline = true
example.run
Resque.inline = previous_value
end
scenario "delivering a message from swordfish to a member" do
# Make sure it enqueues a resque job
expect(ShortMessages::DeliverJob).to receive(:enqueue).and_call_original
# Make sure the resque job works correctly
expect { message.deliver }.to change { stubbed_sms.count }.by(1)
end
scenario "delivering a delayed message to a member" do
expect(ShortMessages::DeliverJob).to_not recieve(:enqueue)
time_travel_to(Time.now + 11.minutes)
expect {
SmsMessages::SendQueuedMessagesJob.perform
}.to change { stubbed_sms.count }.by (1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment