Sha256: b3ae1454c59180a550123a0f218b7646c24f43a0cd593be2aeea3f83f304c712
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
require 'spec_helper' describe NotificationCenter do describe '.post_notification' do before { NotificationCenter::Cache.flush_cache! } it "should fire event handler" do EventListener = Class.new { observe :event } EventListener.should_receive(:event_handler) NotificationCenter.post_notification :event end it "should not raise any exception when no event" do NotificationCenter.post_notification :imaginary_event end context 'when cache disabled' do before { NotificationCenter.enable_cache = false } it "should not fire event twice" do EventListener = Class.new { observe :event } EventListener.should_receive(:event_handler).twice NotificationCenter.post_notification :event NotificationCenter.post_notification :event end it "should return result" do EventListener = Class.new { observe :event } EventListener.should_receive(:event_handler).and_return(:result) NotificationCenter.post_notification(:event).should eql(:result) end end context 'when cache enabled' do before { NotificationCenter.enable_cache = true } it "should not fire event twice" do EventListener = Class.new { observe :event } EventListener.should_receive :event_handler NotificationCenter.post_notification :event NotificationCenter.post_notification :event end it "should return result" do EventListener = Class.new { observe :event } EventListener.should_receive(:event_handler).and_return(:result) NotificationCenter.post_notification(:event).should eql(:result) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
notification_center-0.3.2 | spec/lib/notification_center_spec.rb |