Sha256: f2d117dd6d0fcc5d888fd41026c337f868dddd85578b45aaf7f3ca7fa4448fb6

Contents?: true

Size: 1.7 KB

Versions: 13

Compression:

Stored size: 1.7 KB

Contents

# require 'spec_helper'

# describe Firehose::Consumer do
#   include EM::TestHelper

#   let(:consumer)  { Firehose::Consumer.new }
#   let(:publisher) { Firehose::Publisher.new }
#   let(:channel)   { '/papa-smurf' }
#   let(:another_channel)  { '/mama-smurf' }

#   describe "subscriptions" do
#     it "should subscribe to channel" do
#       sent, recieved = 'hi', nil

#       em do
#         consumer.subscribe_to channel do |msg|
#           recieved = msg
#           em.stop
#         end
#         em.add_timer(1) do
#           publisher.publish(channel, sent)
#         end
#       end

#       recieved.should == sent
#     end

#     it "should track subscriptions" do
#       lambda{
#         em do
#           consumer.subscribe_to channel
#           consumer.subscribe_to another_channel
#           em.add_timer(1){ em.stop }
#         end
#       }.should change{ consumer.subscriptions.size }.by(2)
#     end

#     it "should only allow one subscription per channel" do
#       lambda{
#         em do
#           3.times { consumer.subscribe_to channel }
#           em.add_timer(1){ em.stop }
#         end
#       }.should change{ consumer.subscriptions.size }.by(1)
#     end

#     it "should unsubscribe from all channels" do
#       subscribed_count, after_unsubscribe_count = 0, nil

#       em do
#         consumer.subscribe_to channel
#         consumer.subscribe_to another_channel
#         subscribed_count = consumer.subscriptions.size
#         em.add_timer(1) do 
#           consumer.unsubscribe
#           em.add_timer(1) do 
#             em.stop
#           end
#         end
#       end

#       subscribed_count.should == 2
#       consumer.subscriptions.size.should == 0
#     end
#   end
# end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
firehose-1.1.1 spec/lib/consumer_spec.rb
firehose-1.1.0 spec/lib/consumer_spec.rb
firehose-1.0.0 spec/lib/consumer_spec.rb
firehose-0.2.alpha.10 spec/lib/consumer_spec.rb
firehose-0.2.alpha.9 spec/lib/consumer_spec.rb
firehose-0.2.alpha.8 spec/lib/consumer_spec.rb
firehose-0.2.alpha.7 spec/lib/consumer_spec.rb
firehose-0.2.alpha.6 spec/lib/consumer_spec.rb
firehose-0.2.alpha.5 spec/lib/consumer_spec.rb
firehose-0.2.alpha.3 spec/lib/consumer_spec.rb
firehose-0.2.alpha.2 spec/lib/consumer_spec.rb
firehose-0.1.1 spec/lib/consumer_spec.rb
firehose-0.1.0 spec/lib/consumer_spec.rb