Sha256: d4ce140fce5875309bddb597daef6ed6bb400123dfa0de3f2dc7d1785e48c76a

Contents?: true

Size: 909 Bytes

Versions: 5

Compression:

Stored size: 909 Bytes

Contents

require 'spec_helper'

describe Zenvia::Request do
  describe "#post" do
    let(:params) { {
      to:        '5511971889422',
      message:   "Message sent by parafuzo.com",
      dispatch:  :send,
      id:        "42",
      callback_option: 2
    } }

    def do_post
      subject.post params
    end

    it "should return a parsed response" do
      VCR.use_cassette('zenvia_request') do
        response = do_post

        response[:code].should    eq "000"
        response[:message].should eq "Message Sent"
      end
    end

    context "when an error occurs" do
      let(:params) { {
        to:       '5511971889422',
        dispatch: :send,
        id:       "42"
      } }

      it "should raise an exception" do
        VCR.use_cassette('zenvia_request_error') do
          expect { do_post }.to raise_error Zenvia::Error, 'Empty message content'
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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