Module: PluginTestHelper::Extensions::Configuration

Defined in:
lib/plugin_test_helper/extensions/configuration.rb

Overview

Overrides some of the default values in the Rails configuration so that files can be reused from this test helper or overridden by the plugin using the helper

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.alias_method_chain(klass, target, feature) ⇒ Object

Defines a "lite" version of ActiveSupport's alias chaining extensions. This is defined here and acts on a particular class so as to not conflict with other classes that we have no control over



21
22
23
24
25
26
27
# File 'lib/plugin_test_helper/extensions/configuration.rb', line 21

def self.alias_method_chain(klass, target, feature)
  with_method, without_method = "#{target}_with_#{feature}", "#{target}_without_#{feature}"
  klass.class_eval do
    alias_method without_method, target
    alias_method target, with_method
  end
end

.included(base) ⇒ Object

:nodoc:



9
10
11
12
13
14
15
16
# File 'lib/plugin_test_helper/extensions/configuration.rb', line 9

def self.included(base) #:nodoc:
  alias_method_chain base, :environment_path, :test_helper
  alias_method_chain base, :default_load_paths, :test_helper
  alias_method_chain base, :default_database_configuration_file, :test_helper
  alias_method_chain base, :default_routes_configuration_file, :test_helper
  alias_method_chain base, :default_controller_paths, :test_helper
  alias_method_chain base, :default_plugin_locators, :test_helper
end

Instance Method Details

#environment_path_with_test_helper ⇒ Object

Load the environment file from the plugin or the helper



30
31
32
33
# File 'lib/plugin_test_helper/extensions/configuration.rb', line 30

def environment_path_with_test_helper
  environment_path = environment_path_without_test_helper
  File.exists?(environment_path) ? environment_path : "#{HELPER_RAILS_ROOT}/config/environments/#{environment}.rb"
end