Sha256: 5d3d5382450e33914852c08e0cd30296e442781d96a7b9bfccff8fd176d051cd

Contents?: true

Size: 1.78 KB

Versions: 27

Compression:

Stored size: 1.78 KB

Contents

# -*- encoding: utf-8 -*-

require 'spec_helper'

shared_examples_for "standard Client" do

  before(:each) do
    @destination = "/queue/test/ruby/client"
    @message_text = "test_client-#{Time.now.to_i}"
  end

  describe "the closed? method" do
    it "should be false when the connection is open" do
      @mock_connection.stub!(:closed?).and_return(false)
      @client.closed?.should == false
    end

    it "should be true when the connection is closed" do
      @mock_connection.stub!(:closed?).and_return(true)
      @client.closed?.should == true
    end
  end

  describe "the open? method" do
    it "should be true when the connection is open" do
      @mock_connection.stub!(:open?).and_return(true)
      @client.open?.should == true
    end

    it "should be false when the connection is closed" do
      @mock_connection.stub!(:open?).and_return(false)
      @client.open?.should == false
    end
  end

  describe "the subscribe method" do

    before(:each) do
      @mock_connection.stub!(:subscribe).and_return(true)
    end

    it "should raise RuntimeError if not passed a block" do
      lambda {
        @client.subscribe(@destination)
      }.should raise_error
    end

    it "should not raise an error when passed a block" do
      lambda {
        @client.subscribe(@destination) {|msg| received = msg}
      }.should_not raise_error
    end

    it "should raise RuntimeError on duplicate subscriptions" do
      lambda {
        @client.subscribe(@destination)
        @client.subscribe(@destination)
      }.should raise_error
    end

    it "should raise RuntimeError with duplicate id headers" do
      lambda {
        @client.subscribe(@destination, {'id' => 'abcdef'})
        @client.subscribe(@destination, {'id' => 'abcdef'})
      }.should raise_error
    end

  end

end

Version data entries

27 entries across 25 versions & 2 rubygems

Version Path
stomp-1.3.4 spec/client_shared_examples.rb
stomp-1.3.3 spec/client_shared_examples.rb
stomp-1.3.2 spec/client_shared_examples.rb
stomp-1.3.1 spec/client_shared_examples.rb
stomp-1.3.0 spec/client_shared_examples.rb
stomp-1.2.16 spec/client_shared_examples.rb
stomp-1.2.14 spec/client_shared_examples.rb
stomp-1.2.13 spec/client_shared_examples.rb
stomp-1.2.12 spec/client_shared_examples.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/stomp-1.2.8/spec/client_shared_examples.rb
stomp-1.2.11 spec/client_shared_examples.rb
stomp-1.2.10 spec/client_shared_examples.rb
torquebox-console-0.2.5 vendor/bundle/jruby/1.9/gems/stomp-1.2.8/spec/client_shared_examples.rb
torquebox-console-0.2.5 vendor/bundle/ruby/1.8/gems/stomp-1.2.8/spec/client_shared_examples.rb
stomp-1.2.9 spec/client_shared_examples.rb
torquebox-console-0.2.4 vendor/bundle/ruby/1.8/gems/stomp-1.2.8/spec/client_shared_examples.rb
torquebox-console-0.2.4 vendor/bundle/jruby/1.9/gems/stomp-1.2.8/spec/client_shared_examples.rb
torquebox-console-0.2.3 vendor/bundle/jruby/1.9/gems/stomp-1.2.8/spec/client_shared_examples.rb
stomp-1.2.8 spec/client_shared_examples.rb
stomp-1.2.7 spec/client_shared_examples.rb