Sha256: 23112b2e7c28edc64a83681acff16aebc2a31aa88530a31e02d0bf53384d8aa5

Contents?: true

Size: 1.48 KB

Versions: 7

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'

describe APIMatchers::HTTPStatusCode::BeInternalServerError do
  describe "should be_internal_server_error" do
    it "should passes if the actual is equal to 500" do
      500.should be_internal_server_error
    end

    it "should fails if the actual is not equal to 500" do
      expect { 401.should be_internal_server_error }.to fail_with(%Q{expected that '401' to be Internal Server Error with the status '500'.})
    end
  end

  describe "should_not be_internal_server_error" do
    it "should passes if the actual is not equal to 500" do
      400.should_not be_internal_server_error
    end

    it "should fail if the actual is equal to 500" do
      expect { 500.should_not be_internal_server_error }.to fail_with(%Q{expected that '500' to NOT be Internal Server Error.})
    end
  end

  describe "with change configuration" do
    before do
      APIMatchers.setup { |config| config.http_status_method = :http_status }
    end

    after do
      APIMatchers.setup { |config| config.http_status_method = nil }
    end

    it "should pass if the actual.http_status is equal to 500" do
      response = OpenStruct.new(:http_status => 500)
      response.should be_internal_server_error
    end

    it "should fail if the actual.http_status is not equal to 500" do
      response = OpenStruct.new(:http_status => 402)
      expect { response.should be_internal_server_error }.to fail_with(%Q{expected that '402' to be Internal Server Error with the status '500'.})
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
api_matchers-0.4.0 spec/api_matchers/http_status_code/be_internal_server_error_spec.rb
api_matchers-0.3.0 spec/api_matchers/http_status_code/be_internal_server_error_spec.rb
api_matchers-0.2.0 spec/api_matchers/http_status_code/be_internal_server_error_spec.rb
api_matchers-0.1.1 spec/api_matchers/http_status_code/be_internal_server_error_spec.rb
api_matchers-0.1.0 spec/api_matchers/http_status_code/be_internal_server_error_spec.rb
api_matchers-0.0.2 spec/api_matchers/http_status_code/be_internal_server_error_spec.rb
api_matchers-0.0.1 spec/api_matchers/http_status_code/be_internal_server_error_spec.rb