loggable 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/loggable/logger_stub.rb +3 -3
- data/lib/loggable/version.rb +1 -1
- data/test/examples/log_methods_test.rb +40 -40
- data/test/examples/logger_stub_test.rb +10 -10
- data/test/test_helper.rb +3 -1
- metadata +6 -6
data/lib/loggable/logger_stub.rb
CHANGED
data/lib/loggable/version.rb
CHANGED
@@ -8,47 +8,47 @@ end
|
|
8
8
|
|
9
9
|
module MyModule; end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@logger = mock()
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
it "should allow access to the logger from an instance" do
|
36
|
-
MyClass.logger = @logger
|
37
|
-
MyClass.new.logger.should.equal @logger
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
11
|
+
class LogMethodsTest < Test::Unit::TestCase
|
12
|
+
context "An instance of MyClass, with loggable mix-in" do
|
13
|
+
|
14
|
+
setup { @logger = mock() }
|
15
|
+
teardown { MyClass.logger = nil}
|
16
|
+
|
17
|
+
should "have a logger stub by default" do
|
18
|
+
MyClass.logger.should be_kind_of(LoggerStub)
|
19
|
+
end
|
20
|
+
|
21
|
+
should "not fail when an instance calls an uninitialized logger" do
|
22
|
+
m = MyClass.new
|
23
|
+
lambda { m.logged_method }.should_not raise_error
|
24
|
+
end
|
25
|
+
|
26
|
+
should "allow the asssignment of a logger" do
|
27
|
+
MyClass.logger = @logger
|
28
|
+
MyClass.logger.should == @logger
|
29
|
+
end
|
30
|
+
|
31
|
+
should "allow access to the logger from an instance" do
|
32
|
+
MyClass.logger = @logger
|
33
|
+
MyClass.new.logger.should == @logger
|
34
|
+
end
|
41
35
|
|
42
|
-
describe "MyModule, with loggable mix-in" do
|
43
|
-
|
44
|
-
it "should have a logger stub by default" do
|
45
|
-
MyModule.logger.should.be.an.instance_of(LoggerStub)
|
46
36
|
end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
37
|
+
|
38
|
+
context "MyModule, with loggable mix-in" do
|
39
|
+
|
40
|
+
should "have a logger stub by default" do
|
41
|
+
MyModule.logger = nil
|
42
|
+
MyModule.logger.should be_kind_of(LoggerStub)
|
43
|
+
end
|
44
|
+
|
45
|
+
should "be able to log messages" do
|
46
|
+
logger = mock()
|
47
|
+
logger.expects(:debug).with('blip')
|
48
|
+
|
49
|
+
MyModule.logger = logger
|
50
|
+
MyModule.logger.debug('blip')
|
51
|
+
end
|
52
|
+
|
52
53
|
end
|
53
|
-
|
54
54
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../test_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
@logger = LoggerStub.new
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
class LoggerStubTest < Test::Unit::TestCase
|
4
|
+
context "An instance of the LoggerStub class" do
|
5
|
+
|
6
|
+
setup { @logger = LoggerStub.new }
|
7
|
+
|
8
|
+
should "return nil for all standard logging methods" do
|
9
|
+
[:debug, :error, :fatal, :info, :warn].each do |method|
|
10
|
+
@logger.send(method, 'message').should be(nil)
|
11
|
+
end
|
12
12
|
end
|
13
|
+
|
13
14
|
end
|
14
|
-
|
15
15
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loggable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Reagan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-04-29 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -24,17 +24,17 @@ extra_rdoc_files:
|
|
24
24
|
files:
|
25
25
|
- README.rdoc
|
26
26
|
- Rakefile
|
27
|
-
- lib/loggable
|
28
27
|
- lib/loggable/log_methods.rb
|
29
28
|
- lib/loggable/logger_stub.rb
|
30
29
|
- lib/loggable/version.rb
|
31
30
|
- lib/loggable.rb
|
32
|
-
- test/examples
|
33
31
|
- test/examples/log_methods_test.rb
|
34
32
|
- test/examples/logger_stub_test.rb
|
35
33
|
- test/test_helper.rb
|
36
34
|
has_rdoc: true
|
37
35
|
homepage: http://viget.com/extend
|
36
|
+
licenses: []
|
37
|
+
|
38
38
|
post_install_message:
|
39
39
|
rdoc_options:
|
40
40
|
- --main
|
@@ -56,9 +56,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements: []
|
57
57
|
|
58
58
|
rubyforge_project: viget
|
59
|
-
rubygems_version: 1.3.
|
59
|
+
rubygems_version: 1.3.2
|
60
60
|
signing_key:
|
61
|
-
specification_version:
|
61
|
+
specification_version: 3
|
62
62
|
summary: A gem that provides logging capabilities to any class
|
63
63
|
test_files: []
|
64
64
|
|