Sha256: a531f453a49f931dcd43fa3473c85b1243271e02ce94d35f6bdae62e54319f17

Contents?: true

Size: 1.24 KB

Versions: 48

Compression:

Stored size: 1.24 KB

Contents

require 'test_helper'

class ApplicationConfigurationExtensionsTest < ActiveSupport::TestCase

  test 'Rails.application.config has extension' do
    cfg = Rails.application&.config
    skip unless cfg
    assert cfg.respond_to?(:incline_appconfig_original_database_configuration)
  end

  test 'provide default when config missing' do
    cfg = Rails::Application::Configuration.new

    # method must already be defined.
    assert cfg.methods.include?(:incline_appconfig_original_database_configuration)

    # first we'll confirm that the overridden method is getting called.
    silence_warnings do
      def cfg.incline_appconfig_original_database_configuration
        raise 'Just Testing'
      end
    end

    begin
      cfg.database_configuration
      assert false
    rescue
      assert $!.message =~ /just testing/i
    end

    # now we'll pretend there is no configuration file.
    silence_warnings do
      def cfg.incline_appconfig_original_database_configuration
        raise 'Could not load database configuration. No such file - fake/database.yml'
      end
    end

    db_cfg = cfg.database_configuration

    assert db_cfg.is_a?(::Hash)
    assert db_cfg['test']
    assert db_cfg['development']
    assert_nil db_cfg['production']
  end

end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
incline-0.3.14 test/extensions/application_configuration_extensions_test.rb
incline-0.3.13 test/extensions/application_configuration_extensions_test.rb
incline-0.3.12 test/extensions/application_configuration_extensions_test.rb
incline-0.3.11 test/extensions/application_configuration_extensions_test.rb
incline-0.3.10 test/extensions/application_configuration_extensions_test.rb
incline-0.3.9 test/extensions/application_configuration_extensions_test.rb
incline-0.3.8 test/extensions/application_configuration_extensions_test.rb
incline-0.3.7 test/extensions/application_configuration_extensions_test.rb
incline-0.3.6 test/extensions/application_configuration_extensions_test.rb
incline-0.3.5 test/extensions/application_configuration_extensions_test.rb
incline-0.3.4 test/extensions/application_configuration_extensions_test.rb
incline-0.3.3 test/extensions/application_configuration_extensions_test.rb
incline-0.3.2 test/extensions/application_configuration_extensions_test.rb
incline-0.3.1 test/extensions/application_configuration_extensions_test.rb
incline-0.3.0 test/extensions/application_configuration_extensions_test.rb
incline-0.2.36 test/extensions/application_configuration_extensions_test.rb
incline-0.2.35 test/extensions/application_configuration_extensions_test.rb
incline-0.2.34 test/extensions/application_configuration_extensions_test.rb
incline-0.2.28 test/extensions/application_configuration_extensions_test.rb
incline-0.2.27 test/extensions/application_configuration_extensions_test.rb