Sha256: f2750d4ba1b364b4984a9d615d9f892d13da5169599ef634acd1c3eb91fee8d2
Contents?: true
Size: 1.91 KB
Versions: 3
Compression:
Stored size: 1.91 KB
Contents
require 'spec_helper' describe Cellular::Backends::CoolSMS do let(:recipient) { '47xxxxxxxx' } let(:sender) { 'Custom sender' } let(:message) { 'This is an SMS message' } let(:options) { { recipient: recipient, sender: sender, message: message } } before do Cellular.config.username = 'username' Cellular.config.password = 'password' end describe '::deliver' do before do stub_request(:get, 'https://sms.coolsmsc.dk/?charset=utf-8&from=Custom%20sender&lang=en&message=This%20is%20an%20SMS%20message&password=password&resulttype=xml&to=47xxxxxxxx&username=username'). to_return headers: { 'Content-Type' => 'text/xml' }, body: fixture('backends/cool_sms/success.xml') end it 'uses HTTParty to deliver an SMS' do expect(HTTParty).to receive(:get).with(described_class::GATEWAY_URL, query: { username: 'username', password: 'password', from: sender, to: recipient, message: message, charset: 'utf-8', resulttype: 'xml', lang: 'en' }).and_call_original described_class.deliver(options) end context 'when successful' do it 'returns success and a message' do expect(described_class.deliver(options)).to eq [ 'success', 'The message was sent correctly.' ] end end context 'when not successful' do before do stub_request(:get, 'https://sms.coolsmsc.dk/?charset=utf-8&from=Custom%20sender&lang=en&message=This%20is%20an%20SMS%20message&password=password&resulttype=xml&to=47xxxxxxxx&username=username'). to_return headers: { 'Content-Type' => 'text/xml' }, body: fixture('backends/cool_sms/failure.xml') end it 'returns failure and a message' do expect(described_class.deliver(options)).to eq [ 'failure', 'Access denied.' ] end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cellular-1.3.0 | spec/cellular/backends/cool_sms_spec.rb |
cellular-1.2.0 | spec/cellular/backends/cool_sms_spec.rb |
cellular-1.1.0 | spec/cellular/backends/cool_sms_spec.rb |