Sha256: 94855a98fadbb8a822a69028d52e1e82717dcc174d4528a2c69560b0d5004b0d

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

# -*- encoding: utf-8 -*-
require 'spec_helper'

module OnStomp::Components::Scopes
  describe ReceiptScope do
    let(:client) {
      OnStomp::Client.new("stomp:///")
    }
    let(:receipt_back) {
      lambda { |r| true }
    }
    let(:scope) {
      ReceiptScope.new receipt_back, client
    }
    
    let(:frame_method_interface) { scope }
    it_should_behave_like "frame method interfaces"

    it "sets up the connection attribute" do
      connection = stub('connection')
      client.should_receive(:connection).and_return(connection)
      scope.connection.should == connection
    end
    
    describe ".transmit" do
      it "should add its receipt callback to frames transmitted without one" do
        frame = OnStomp::Components::Frame.new('COMMAND', {:header2 => 'my value'})
        client.should_receive(:transmit).with(frame, { :receipt => receipt_back })
        scope.transmit frame
      end
      it "should not add its receipt callback if one was already present" do
        alt_receipt_back = lambda { |r| false }
        frame = OnStomp::Components::Frame.new('COMMAND', {:header2 => 'my value'})
        client.should_receive(:transmit).with(frame, { :receipt => alt_receipt_back })
        scope.transmit frame, :receipt => alt_receipt_back
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
onstomp-1.0.12 spec/onstomp/components/scopes/receipt_scope_spec.rb
onstomp-1.0.11 spec/onstomp/components/scopes/receipt_scope_spec.rb
onstomp-1.0.10 spec/onstomp/components/scopes/receipt_scope_spec.rb
onstomp-1.0.9 spec/onstomp/components/scopes/receipt_scope_spec.rb
onstomp-1.0.8 spec/onstomp/components/scopes/receipt_scope_spec.rb
onstomp-1.0.7 spec/onstomp/components/scopes/receipt_scope_spec.rb
onstomp-1.0.6 spec/onstomp/components/scopes/receipt_scope_spec.rb