Sha256: 8482a83cdb32ab3b8665b4be97bdef8796317cf5dac7558279f051d106a3845c

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

module Stomper
  describe ThreadedReceiver do
    before(:each) do
      @connection = mock("connection")
      @connection.extend Stomper::ThreadedReceiver
    end
    
    describe "expected interface" do
      it "should provide a start method" do
        @connection.should respond_to(:start)
      end
      
      it "should provide a stop method" do
        @connection.should respond_to(:stop)
      end
    end
    
    describe "reading on a thread" do
      it "should start receiving when started, and stop when stopped." do
        @connection.should_receive(:connected?).once.and_return(false)
        @connection.should_receive(:connect).once.and_return(true)
        @connection.should_receive(:connected?).any_number_of_times.and_return(true)
        @connection.should_receive(:receive).at_least(:once).and_return(nil)
        @connection.start
        sleep(0.5)
        @connection.stop
        @connection.should_not_receive(:receive)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stomper-1.0.0 spec/threaded_receiver_spec.rb