Sha256: 7512a77496d2a5840705d01f1d6ff34c63e0c9e0859661f09f93c5e650c7e521

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

describe Gaffe do
  describe :ClassMethods do
    describe :configure do
      let(:configuration) { Gaffe.configuration }
      before do
        Gaffe.configure do |config|
          config.foo = :bar
          config.bar = :foo
        end
      end

      it { expect(configuration.foo).to eql :bar }
      it { expect(configuration.bar).to eql :foo }
    end

    describe :enable! do
      let(:env) { test_request.env }
      let(:action_double) { double(call: proc { [400, {}, 'SOMETHING WENT WRONG.'] }) }
      before { Gaffe.enable! }

      specify do
        expect(Gaffe).to receive(:errors_controller_for_request).with(env).and_call_original
        expect(Gaffe::ErrorsController).to receive(:action).with(:show).and_return(action_double)
        expect(action_double).to receive(:call).with(env)

        # This is the line Rails itself calls
        # https://github.com/rails/rails/blob/fee49a10492efc99409c03f7096d5bd3377b0bbc/actionpack/lib/action_dispatch/middleware/show_exceptions.rb#L43
        Rails.application.config.exceptions_app.call(env)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gaffe-1.2.0 spec/gaffe/gaffe_spec.rb
gaffe-1.1.0 spec/gaffe/gaffe_spec.rb