Sha256: cb0e0fa0ea812aa75c98c89d58f97372b3b8560ccdbf5edb955c2aef2ac5e7a3
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
# -*- encoding: utf-8 -*- require 'spec_helper' module OnStomp::Interfaces describe ConnectionEvents do let(:client) { mock('client') } let(:eventable) { mock('eventable', :client => client).tap do |m| m.extend ConnectionEvents end } describe "connection event methods" do it "should provide a 'on_established' event" do triggered = false eventable.on_established { triggered = true } eventable.trigger_connection_event :established triggered.should be_true end it "should provide a 'on_closed' event" do triggered = false eventable.on_closed { triggered = true } eventable.trigger_connection_event :closed triggered.should be_true end it "should provide a 'on_died' event" do triggered = false eventable.on_died { triggered = true } eventable.trigger_connection_event :died triggered.should be_true end it "should provide a 'on_terminated' event" do triggered = false eventable.on_terminated { triggered = true } eventable.trigger_connection_event :terminated triggered.should be_true end end describe ".install_bindings_from_client" do let(:callback1) { mock('callback1') } let(:callback2) { mock('callback2') } let(:callback3) { mock('callback3') } it "should bind events from the hash and trigger connected" do eventable.should_receive(:bind_event).with(:ev1, callback3) eventable.should_receive(:bind_event).with(:ev1, callback2) eventable.should_receive(:bind_event).with(:ev2, callback1) eventable.should_receive(:trigger_connection_event).with(:established) eventable.install_bindings_from_client :ev1 => [callback3, callback2], :ev2 => [callback1] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
onstomp-1.0.0pre1 | spec/onstomp/interfaces/connection_events_spec.rb |