spec/cellular/jobs/async_messenger_spec.rb in cellular-2.0.0 vs spec/cellular/jobs/async_messenger_spec.rb in cellular-2.1.0

- old
+ new

@@ -2,23 +2,24 @@ describe Cellular::Jobs::AsyncMessenger do let(:sms_stub) { double "SMS", deliver: true } let(:sms_options) { { "recipient" => "12345678", "text" => "Foo" } } + before do + allow(Cellular::SMS).to receive(:new).and_return sms_stub + end + it 'creates a new SMS object' do symbolized_sms_options = { recipient: "12345678", text: "Foo" } - expect(Cellular::SMS).to receive(:new) - .with(symbolized_sms_options) - .and_return sms_stub - subject.perform sms_options + + expect(Cellular::SMS).to have_received(:new) + .with(symbolized_sms_options) end it "delivers the SMS" do - allow(Cellular::SMS).to receive(:new).and_return sms_stub - - expect(sms_stub).to receive :deliver - subject.perform sms_options + + expect(sms_stub).to have_received :deliver end end