Sha256: bc16a019fd0fd2391cb7e98dafdf756eacfe458fb994b63d7fb92c17e82ad5e4

Contents?: true

Size: 1.03 KB

Versions: 5

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, callback_option: 2
        })

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
zenvia-0.0.8 spec/zenvia/sms_spec.rb
zenvia-0.0.7 spec/zenvia/sms_spec.rb
zenvia-0.0.6 spec/zenvia/sms_spec.rb
zenvia-0.0.5 spec/zenvia/sms_spec.rb
zenvia-0.0.4 spec/zenvia/sms_spec.rb