Sha256: 04ce3ebe1d80fe1ed349e5760c42ad6389590c508c4568fc7096844a6c4907be

Contents?: true

Size: 883 Bytes

Versions: 3

Compression:

Stored size: 883 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"
    } }

    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

3 entries across 3 versions & 1 rubygems

Version Path
zenvia-0.0.3 spec/zenvia/request_spec.rb
zenvia-0.0.2 spec/zenvia/request_spec.rb
zenvia-0.0.1 spec/zenvia/request_spec.rb