forked from SAML-Toolkits/ruby-saml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogging_test.rb
62 lines (47 loc) · 1.52 KB
/
logging_test.rb
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
require File.expand_path(File.join(File.dirname(__FILE__), "test_helper"))
require 'onelogin/ruby-saml/logging'
class LoggingTest < Minitest::Test
describe "Logging" do
before do
OneLogin::RubySaml::Logging.logger = nil
end
after do
OneLogin::RubySaml::Logging.logger = ::TEST_LOGGER
end
describe "given no specific logging setup" do
it "prints to stdout" do
OneLogin::RubySaml::Logging::DEFAULT_LOGGER.expects(:debug).with('hi mom')
OneLogin::RubySaml::Logging.debug('hi mom')
end
end
describe "given a Rails app" do
let(:logger) { mock('Logger') }
before do
::Rails = mock('Rails module')
::Rails.stubs(:logger).returns(logger)
end
after do
Object.instance_eval { remove_const(:Rails) }
end
it "delegates to Rails" do
logger.expects(:debug).with('hi mom')
logger.expects(:info).with('sup?')
OneLogin::RubySaml::Logging.debug('hi mom')
OneLogin::RubySaml::Logging.info('sup?')
end
end
describe "given a specific Logger" do
let(:logger) { mock('Logger') }
before { OneLogin::RubySaml::Logging.logger = logger }
after do
OneLogin::RubySaml::Logging.logger = ::TEST_LOGGER
end
it "delegates to the object" do
logger.expects(:debug).with('hi mom')
logger.expects(:info).with('sup?')
OneLogin::RubySaml::Logging.debug('hi mom')
OneLogin::RubySaml::Logging.info('sup?')
end
end
end
end