Sha256: 027b757eda644739bb64725359fedb11bded6a9d60698f45b7415edd13502851

Contents?: true

Size: 1.22 KB

Versions: 95

Compression:

Stored size: 1.22 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)

          subject.error_map.should have(1).item
        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

          subject.error_map[400].should 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
        subject.message.should eq("<html><body><h1>Redirected</h1></body></html>")
      end
    end
  end
end

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
ridley-4.2.0 spec/unit/ridley/errors_spec.rb
ridley-4.1.2 spec/unit/ridley/errors_spec.rb
ridley-4.1.1 spec/unit/ridley/errors_spec.rb
ridley-4.1.0 spec/unit/ridley/errors_spec.rb
ridley-4.0.0 spec/unit/ridley/errors_spec.rb
ridley-3.1.0 spec/unit/ridley/errors_spec.rb
ridley-3.0.0 spec/unit/ridley/errors_spec.rb
ridley-3.0.0.rc1 spec/unit/ridley/errors_spec.rb
ridley-2.5.1 spec/unit/ridley/errors_spec.rb
ridley-2.5.0 spec/unit/ridley/errors_spec.rb
ridley-2.4.4 spec/unit/ridley/errors_spec.rb
ridley-2.4.3 spec/unit/ridley/errors_spec.rb
ridley-2.4.2 spec/unit/ridley/errors_spec.rb
ridley-2.4.1 spec/unit/ridley/errors_spec.rb
ridley-2.4.0 spec/unit/ridley/errors_spec.rb
ridley-2.3.0 spec/unit/ridley/errors_spec.rb
ridley-2.2.0 spec/unit/ridley/errors_spec.rb
ridley-2.1.0 spec/unit/ridley/errors_spec.rb
ridley-2.0.0 spec/unit/ridley/errors_spec.rb
ridley-1.7.1 spec/unit/ridley/errors_spec.rb