Sha256: 4c4a9e6be6034154316a5c99f2e3ea29768ff77098f2605f83770e919a60c0b1

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 Bytes

Contents

require File.dirname(__FILE__) + '/spec_helper'
require File.dirname(__FILE__) + '/../lib/clickatell'

module Clickatell

  describe "Response parser" do
    before do
      @raw_response = stub('response')
      Clickatell::API::Error.stub!(:parse).and_return(Clickatell::API::Error.new('', ''))
    end
    
    it "should return hash for one-line success response" do
      @raw_response.stub!(:body).and_return('k1: foo k2: bar')
      Response.parse(@raw_response).should == {'k1' => 'foo', 'k2' => 'bar'}
    end
    
    it "should raise API::Error if response contains an error message" do
      @raw_response.stub!(:body).and_return('ERR: 001, Authentication failed')
      proc { Response.parse(@raw_response) }.should raise_error(Clickatell::API::Error)
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clickatell-0.3.0 spec/response_spec.rb
clickatell-0.4.0 spec/response_spec.rb
clickatell-0.4.1 spec/response_spec.rb