1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
require 'test_helper'
class SamuelTest < Test::Unit::TestCase
context "logger configuration" do
setup do
Samuel.logger = nil
Object.send(:remove_const, :Rails) if Object.const_defined?(:Rails)
end
teardown do
Samuel.logger = nil
end
context "when Rails's logger is available" do
setup { Object.const_set(:Rails, stub(:logger => :mock_logger)) }
should "use the same logger" do
assert_equal :mock_logger, Samuel.logger
end
end
context "when Rails's logger is not available" do
should "use a new Logger instance pointed to STDOUT" do
assert_instance_of Logger, Samuel.logger
assert_equal STDOUT, Samuel.logger.instance_variable_get(:"@logdev").dev
end
end
end
context ".reset_config" do
should "reset the config to default vaules" do
Samuel.config = {:foo => "bar"}
Samuel.reset_config
assert_equal({:label => nil, :labels => {}, :filtered_params => []}, Samuel.config)
end
end
end
|