Sha256: f27a954c786996da4dffca1db8c1aea9260e594aea4443db428085aaac5cee50

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'

RUMOUR_TEST_ACCESS_TOKEN = '13b91294f69c5e6046274d249911c275e21e013e'
TWILIO_TEST_SENDER_NUMBER = '+15005550006'
TWILIO_TEST_RECIPIENT_NUMBER = '+14108675309'

Rumour.configure do |config|
  config.access_token = 'CONFIGURED_ACCESS_TOKEN'
end

RSpec.describe Rumour::Client do

  describe '.new' do
    it 'sets the authentication credentials' do
      rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)

      expect(rumour_client.access_token).to eq(RUMOUR_TEST_ACCESS_TOKEN)
    end

    it 'falls back to the configuration credentials' do
      rumour_client = Rumour::Client.new

      expect(rumour_client.access_token).to eq('CONFIGURED_ACCESS_TOKEN')
    end
  end

  describe '.send_text_message with valid data' do
    it 'creates and retrieves a new message as a hash' do
      rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
      text_message = rumour_client.send_text_message(TWILIO_TEST_SENDER_NUMBER, TWILIO_TEST_RECIPIENT_NUMBER, 'Hello from rumour-ruby!')

      expect(text_message['id']).to_not be_nil
    end
  end

  describe '.send_text_message with invalid data' do
    it 'creates and retrieves a new message as a hash' do
      rumour_client = Rumour::Client.new(RUMOUR_TEST_ACCESS_TOKEN)
      text_message = rumour_client.send_text_message('+351123456789', '+351123456789', 'Hello from rumour-ruby!')

      expect(text_message['message']).to_not be_nil
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rumour-ruby-0.0.1 spec/client_spec.rb