discourse/vendor/gems/message_bus/spec/lib/client_spec.rb

28 lines
637 B
Ruby
Raw Normal View History

2013-02-05 14:16:51 -05:00
require 'spec_helper'
require 'message_bus'
2013-02-25 11:42:20 -05:00
describe MessageBus::Client do
2013-02-05 14:16:51 -05:00
describe "subscriptions" do
2013-02-25 11:42:20 -05:00
2013-02-05 14:16:51 -05:00
before do
@client = MessageBus::Client.new :client_id => 'abc'
end
2013-02-25 11:42:20 -05:00
it "should provide a list of subscriptions" do
2013-02-05 14:16:51 -05:00
@client.subscribe('/hello', nil)
2013-02-25 11:42:20 -05:00
@client.subscriptions['/hello'].should_not be_nil
2013-02-05 14:16:51 -05:00
end
2013-02-25 11:42:20 -05:00
it "should provide backlog for subscribed channel" do
2013-02-05 14:16:51 -05:00
@client.subscribe('/hello', nil)
MessageBus.publish '/hello', 'world'
2013-02-25 11:42:20 -05:00
log = @client.backlog
2013-02-05 14:16:51 -05:00
log.length.should == 1
log[0].channel.should == '/hello'
log[0].data.should == 'world'
end
end
end