test/examples/log_methods_test.rb in loggable-0.1.0 vs test/examples/log_methods_test.rb in loggable-0.2.0
- old
+ new
@@ -4,16 +4,22 @@
def logged_method
logger.debug 'message'
end
end
+module MyModule; end
+
describe "MyClass, with loggable mix-in" do
before(:each) do
@logger = mock()
end
+ after(:each) do
+ MyClass.logger = nil
+ end
+
it "should have a logger stub by default" do
MyClass.logger.should.be.an.instance_of(LoggerStub)
end
it "should not fail when an instance calls an uninitialized logger" do
@@ -27,8 +33,22 @@
end
it "should allow access to the logger from an instance" do
MyClass.logger = @logger
MyClass.new.logger.should.equal @logger
+ end
+
+end
+
+describe "MyModule, with loggable mix-in" do
+
+ it "should have a logger stub by default" do
+ MyModule.logger.should.be.an.instance_of(LoggerStub)
+ end
+
+ it "should be able to log messages" do
+ logger = mock {|m| m.expects(:debug).with('blip') }
+ MyModule.logger = logger
+ MyModule.logger.debug('blip')
end
end
\ No newline at end of file