Sha256: 4cb22c41a46cdb0a81f6441aef535aa869fe936205e939de5ee8a61fce113845
Contents?: true
Size: 1.6 KB
Versions: 1
Compression:
Stored size: 1.6 KB
Contents
require File.join(File.dirname(__FILE__), *%w[example_helper]) describe Chatterbox do before do Chatterbox.logger = Logger.new(nil) Chatterbox::Publishers.clear! end after do Chatterbox.logger = nil end describe "handle_notice" do include Chatterbox it "should publish the notice" do Chatterbox.expects(:publish_notice).with("message") Chatterbox.handle_notice("message") end end describe "logger" do it "uses STDOUT logger if Rails not available" do Chatterbox.logger = nil Logger.expects(:new).with(STDOUT).returns("logger") Chatterbox.stubs(:rails_default_logger).returns(nil) Chatterbox.logger.should == "logger" end end describe "publish" do include Chatterbox it "should call each publisher with the notice" do notice = stub publisher = Chatterbox::Publishers.register { "i'm in your block" } publisher.expects(:call).with(notice) publish_notice(notice) end end describe "publishers" do it "should allow clearing all publishers" do Chatterbox::Publishers.register { "sending your messages" } Chatterbox::Publishers.publishers.size.should == 1 Chatterbox::Publishers.clear! Chatterbox::Publishers.publishers.size.should == 0 end it "should allow registering with a block" do pub1 = Chatterbox::Publishers.register { "sending your messages" } pub2 = Chatterbox::Publishers.register { "announcing your news" } Chatterbox::Publishers.publishers.should == [pub1, pub2] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
chatterbox-0.4.0 | examples/chatterbox_example.rb |