Sha256: ff9413f9da2d615c8056e17c0cac8e9ab1790629c220b9d8e585eca470728798

Contents?: true

Size: 1.77 KB

Versions: 2

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

if defined?(::Rails)
describe Rack::DevMark::Railtie do
  include_context 'forked spec'

  before do
    @app = Class.new(::Rails::Application)
    @app.config.active_support.deprecation = :stderr
    @app.config.eager_load = false
  end
  context "rack_dev_mark enable" do
    before do
      @app.config.rack_dev_mark.enable = true
    end
    it 'inserts the middleware' do
      @app.initialize!
      expect(@app.middleware.middlewares).to include(Rack::DevMark::Middleware)
    end
  end
  context "rack_dev_mark disable" do
    before do
      @app.config.rack_dev_mark.enable = false
    end
    it 'does not insert the middleware' do
      @app.initialize!
      expect(@app.middleware.middlewares).not_to include(Rack::DevMark::Middleware)
    end
    context "with rack_dev_mark_env" do
      before do
        ENV['RACK_DEV_MARK_ENV'] = 'test'
      end
      it 'inserts the middleware' do
        @app.initialize!
        expect(@app.middleware.middlewares).to include(Rack::DevMark::Middleware)
      end
    end
  end
  context "rack_dev_mark theme" do
    let(:theme) { d = double setup: nil; allow(d).to receive(:insert_into){ |b| "#{b} dev-mark" }; d }
    before do
      @app.config.rack_dev_mark.enable = true
      @app.config.rack_dev_mark.theme = [theme]
    end
    it 'inserts the middleware' do
      @app.initialize!
      expect(theme).to receive(:setup)
    end
  end
  context "rack_dev_mark custom_theme alias" do
    let(:theme) { d = double setup: nil; allow(d).to receive(:insert_into){ |b| "#{b} dev-mark" }; d }
    before do
      @app.config.rack_dev_mark.enable = true
      @app.config.rack_dev_mark.custom_theme = [theme]
    end
    it 'inserts the middleware' do
      @app.initialize!
      expect(theme).to receive(:setup)
    end
  end
end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-dev-mark-0.6.3 spec/rack/dev-mark/railtie_spec.rb
rack-dev-mark-0.6.2 spec/rack/dev-mark/railtie_spec.rb