2016-08-06 13:16:09 -04:00
|
|
|
require "isolation/abstract_unit"
|
2015-05-03 20:25:56 -04:00
|
|
|
|
|
|
|
module ApplicationTests
|
|
|
|
module ConfigurationTests
|
|
|
|
class CustomTest < ActiveSupport::TestCase
|
|
|
|
def setup
|
|
|
|
build_app
|
|
|
|
FileUtils.rm_rf("#{app_path}/config/environments")
|
|
|
|
end
|
|
|
|
|
|
|
|
def teardown
|
|
|
|
teardown_app
|
|
|
|
end
|
|
|
|
|
2016-08-06 13:16:09 -04:00
|
|
|
test "access custom configuration point" do
|
2015-05-03 20:25:56 -04:00
|
|
|
add_to_config <<-RUBY
|
|
|
|
config.x.payment_processing.schedule = :daily
|
|
|
|
config.x.payment_processing.retries = 3
|
|
|
|
config.x.super_debugger = true
|
|
|
|
config.x.hyper_debugger = false
|
|
|
|
config.x.nil_debugger = nil
|
|
|
|
RUBY
|
|
|
|
require_environment
|
|
|
|
|
|
|
|
x = Rails.configuration.x
|
|
|
|
assert_equal :daily, x.payment_processing.schedule
|
|
|
|
assert_equal 3, x.payment_processing.retries
|
|
|
|
assert_equal true, x.super_debugger
|
|
|
|
assert_equal false, x.hyper_debugger
|
2016-12-24 12:29:52 -05:00
|
|
|
assert_nil x.nil_debugger
|
2015-05-03 20:25:56 -04:00
|
|
|
assert_nil x.i_do_not_exist.zomg
|
|
|
|
|
2017-01-19 02:33:30 -05:00
|
|
|
# test that custom configuration responds to all messages
|
2016-07-05 13:28:12 -04:00
|
|
|
assert_equal true, x.respond_to?(:i_do_not_exist)
|
|
|
|
assert_kind_of Method, x.method(:i_do_not_exist)
|
|
|
|
assert_kind_of ActiveSupport::OrderedOptions, x.i_do_not_exist
|
|
|
|
end
|
|
|
|
|
2015-05-03 20:25:56 -04:00
|
|
|
private
|
|
|
|
def require_environment
|
|
|
|
require "#{app_path}/config/environment"
|
|
|
|
end
|
|
|
|
end
|
2014-08-03 18:48:14 -04:00
|
|
|
end
|
|
|
|
end
|