Sha256: 334518395f5d7c1ed7007b7bc770159c7a09ea43824026e29bdd725ff988a223

Contents?: true

Size: 1.23 KB

Versions: 14

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe Ridley::Errors do
  describe Ridley::Errors::HTTPError do
    describe "ClassMethods" do
      subject { Ridley::Errors::HTTPError }

      before(:each) do
        @original = Ridley::Errors::HTTPError.class_variable_get :@@error_map
        Ridley::Errors::HTTPError.class_variable_set :@@error_map, Hash.new
      end

      after(:each) do
        Ridley::Errors::HTTPError.class_variable_set :@@error_map, @original
      end

      describe "::register_error" do
        it "adds an item to the error map" do
          subject.register_error(400)

          expect(subject.error_map.size).to eq(1)
        end

        it "adds a key of the given status code with a value of the class inheriting from HTTPError" do
          class RidleyTestHTTPError < Ridley::Errors::HTTPError
            register_error(400)
          end

          expect(subject.error_map[400]).to eql(RidleyTestHTTPError)
        end
      end
    end

    context "with an HTML error payload" do
      subject { Ridley::Errors::HTTPError.new(:body => "<html><body><h1>Redirected</h1></body></html>") }

      it "has an HTML body" do
        expect(subject.message).to eq("<html><body><h1>Redirected</h1></body></html>")
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
ridley-5.1.1 spec/unit/ridley/errors_spec.rb
ridley-5.1.0 spec/unit/ridley/errors_spec.rb
ridley-5.0.0 spec/unit/ridley/errors_spec.rb
ridley-4.6.1 spec/unit/ridley/errors_spec.rb
ridley-4.6.0 spec/unit/ridley/errors_spec.rb
ridley-4.5.1 spec/unit/ridley/errors_spec.rb
ridley-4.5.0 spec/unit/ridley/errors_spec.rb
ridley-4.4.3 spec/unit/ridley/errors_spec.rb
ridley-4.4.2 spec/unit/ridley/errors_spec.rb
ridley-4.4.1 spec/unit/ridley/errors_spec.rb
ridley-4.4.0 spec/unit/ridley/errors_spec.rb
ridley-4.3.2 spec/unit/ridley/errors_spec.rb
ridley-4.3.1 spec/unit/ridley/errors_spec.rb
ridley-4.3.0 spec/unit/ridley/errors_spec.rb