Sha256: 69bafd9239a4296d22a57af9afecee33a606c092d22adee304a6dd9a10069e93

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe Outbox::Twilio::Client do
  describe '.new' do
    it 'configures the Twilio API client' do
      api_client = double(:api_client)
      expect(::Twilio::REST::Client).to receive(:new).with(
        'AC1',
        'abcdef',
        timeout: 5,
        retry_limit: 2
      ).and_return(api_client)
      client = Outbox::Twilio::Client.new(
        account_sid: 'AC1',
        auth_token: 'abcdef',
        timeout: 5,
        retry_limit: 2
      )
      expect(client.api_client).to be(api_client)
    end
  end

  describe '#deliver' do
    before do
      @client = Outbox::Twilio::Client.new(
        account_sid: 'AC1',
        auth_token: 'abcdef'
      )
      @sms = Outbox::Messages::SMS.new do
        to '+14155551212'
        from 'Company Name'
        body 'Hello world.'
      end
      @sms[:media_url] = 'http://www.example.com/hearts.png'
      @sms[:status_callback] = 'http://www.example.com/callback'
      @sms[:application_sid] = '1234'
    end

    it 'delivers the SMS' do
      expect(@client.api_client.account.messages).to receive(:create).with(
        to: '+14155551212',
        from: 'Company Name',
        body: 'Hello world.',
        media_url: 'http://www.example.com/hearts.png',
        status_callback: 'http://www.example.com/callback',
        application_sid: '1234'
      )
      @client.deliver(@sms)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outbox-twilio-0.2.0 spec/outbox/twilio/client_spec.rb