Sha256: 1cba62a59d6dbbd6e80d8ee3032b5040850eb1abb92a5b58ca3f4008efbbf5b4

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe Uncruft::Railtie do
  let(:app) { Rails.application }
  let(:initializers) { app.initializers.tsort_each.select { |i| i.name.to_s.include?('deprecation') } }

  it 'injects the default deprecation handler' do
    expect { initializers.map { |i| i.run(app) } }.to change { Rails.application.config.active_support.deprecation }
      .from(nil).to(a_collection_containing_exactly(an_instance_of(Uncruft::DeprecationHandler)))
  end

  context 'when the configured behavior is :stderr' do
    before do
      Rails.application.config.active_support.deprecation = :stderr
    end

    it 'injects the default deprecation handler' do
      expect { initializers.map { |i| i.run(app) } }.to change { Rails.application.config.active_support.deprecation }
        .from(:stderr).to(a_collection_containing_exactly(an_instance_of(Uncruft::DeprecationHandler)))
    end
  end

  context 'when a custom deprecation behavior is already configured' do
    before do
      Rails.application.config.active_support.deprecation = :notify
    end

    it 'injects the default deprecation handler' do
      expect { initializers.map { |i| i.run(app) } }.to change { Rails.application.config.active_support.deprecation }
        .from(:notify).to(a_collection_containing_exactly(:notify, an_instance_of(Uncruft::DeprecationHandler)))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uncruft-0.3.0 spec/uncruft/railtie_spec.rb
uncruft-0.2.1 spec/uncruft/railtie_spec.rb
uncruft-0.2.0 spec/uncruft/railtie_spec.rb
uncruft-0.1.0 spec/uncruft/railtie_spec.rb
uncruft-0.0.2 spec/uncruft/railtie_spec.rb
uncruft-0.0.1 spec/uncruft/railtie_spec.rb