Sha256: d178e32804af60c9f6e563e61bdf4629afa6e5ae882ffabff1664788e0cf28a6

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Faraday::Response::RaiseRapidashError do
  context "successful response" do
    let(:env) { { :status => '200' } }

    it "should not raise an exception" do
      expect {
        subject.on_complete(env)
      }.to_not raise_exception(Rapidash::ResponseError)
    end
  end

  context "error response" do
    let(:env) { { :status => '404', :method => 'post', :url => 'http://acme.com/api/posts' } }

    it "should raise an exception" do
      expect {
        subject.on_complete(env)
      }.to raise_exception(Rapidash::ResponseError)
    end

    describe "custom reponse error" do
      before :each do
        class MyCustomResponseError < Rapidash::ResponseError; end
        Rapidash.response_exception_class = MyCustomResponseError
      end

      it "should raise a custom excpetion class if specified" do
        expect {
          subject.on_complete(env)
        }.to raise_exception(MyCustomResponseError)
      end

      after :each do
        Rapidash.response_exception_class = nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rapidash-0.3.1 spec/faraday/raise_rapidash_error_spec.rb
rapidash-0.3.0 spec/faraday/raise_rapidash_error_spec.rb
rapidash-0.3.0.beta2 spec/faraday/raise_rapidash_error_spec.rb
rapidash-0.3.0.beta spec/faraday/raise_rapidash_error_spec.rb