Sha256: 2624326a5f4c2c8a9f2edf419e7ce4ae34d8c69bb7846e731949adbfe72447ca

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe Zenvia::Sms do
  describe "#send" do
    let(:request_mock) { double post: true }

    subject { described_class.new :number, :message }

    before do
      Zenvia::Request.stub(:new).and_return request_mock
    end

    it "should call request with correct params" do
      request_mock.should_receive(:post).with({
        to: :number, message: :message, dispatch: :send
      })

      subject.send
    end

    context "when there is a message id" do
      it "should send id" do
        request_mock.should_receive(:post).with({
          to: :number, message: :message, dispatch: :send, id: 'message id'
        })

        subject.message_id = 'message id'
        subject.send
      end
    end

    context "when there is the callbackOption" do
      it "should send callbackOption" do
        request_mock.should_receive(:post).with({
          to: :number, message: :message, dispatch: :send, callbackOption: 2
        })

        subject.callback_option = 2
        subject.send
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zenvia-0.0.3 spec/zenvia/sms_spec.rb