Sha256: 4f96c700e02e6e877c122cf918dbfb1e70ae429cfe103bf70857809bcd3eb5b2

Contents?: true

Size: 1.08 KB

Versions: 9

Compression:

Stored size: 1.08 KB

Contents

# coding: UTF-8
require 'spec_helper'

describe Rescue::RespondError do

  Rescue::ApplicationError::STATUS_CODES.each do |code, e|
    describe "#{code} #{e[:status]}" do
      let(:name) { e[:status].gsub(' ', '') }

      it "expects to define an exception class of #{e[:status]}" do
        expect(Object.const_defined? name).to be_true
      end

      it "expects to define an exception class that is a kind of Rescue::ApplicationError" do
        expect(Object.const_get(name).new).to be_a_kind_of Rescue::ApplicationError
      end
    end
  end

  describe "HTTP Status Code" do
    context "Suppress Response code is #{Rescue.config.suppress_response_codes}" do
      Rescue::ApplicationError::STATUS_CODES.each do |code, e|
        describe "#{code} #{e[:status]}" do
          before do
            visit "/status//#{code}.json"
          end

          it "expects to return #{Rescue.config.suppress_response_codes ? 200 : e[:http]}" do
            expect(page.status_code).to eq (Rescue.config.suppress_response_codes ? 200 : e[:http])
          end
        end
      end
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rescue-dog-0.3.8 spec/rescue/exceptions/respond_error_spec.rb
rescue-dog-0.3.7 spec/rescue/exceptions/respond_error_spec.rb
rescue-dog-0.3.5 spec/rescue/exceptions/respond_error_spec.rb
rescue-dog-0.3.4 spec/rescue/exceptions/respond_error_spec.rb
rescue-dog-0.3.2 spec/rescue/exceptions/respond_error_spec.rb
rescue-dog-0.3.1 spec/rescue/exceptions/respond_error_spec.rb
rescue-dog-0.3.0 spec/rescue/exceptions/respond_error_spec.rb
rescue-dog-0.2.1 spec/rescue/exceptions/respond_error_spec.rb
rescue-dog-0.2.0 spec/rescue/exceptions/respond_error_spec.rb