Sha256: cfd35a5af2ad6fc20371385cc6fda5a4f14faa1d85fd9471fcb86ea7ab243724
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
require File.dirname(__FILE__) + '/../test_helper' class MyClass 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 m = MyClass.new lambda { m.logged_method }.should.not.raise end it "should allow the asssignment of a logger" do MyClass.logger = @logger MyClass.logger.should.equal @logger 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
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
vigetlabs-loggable-0.2.0 | test/examples/log_methods_test.rb |
loggable-0.2.0 | test/examples/log_methods_test.rb |