Sha256: b357f3baacd8220292595056a8ec984a5fefc821102b79e96f953c84606279ed

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 Bytes

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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ridley-0.0.2 spec/unit/ridley/errors_spec.rb
ridley-0.0.1 spec/unit/ridley/errors_spec.rb