Sha256: ecade58916d2dfe16378ec26eda65cd21c38396cb6c6a240df4be0faefde09de

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require 'rabbit_rpc'

describe RabbitRPC::Message do

  describe '#pack' do
    it 'succesfully shifts the RPC method and its arguments to a single datastructure' do
      message = RabbitRPC::Message.new 'hello', 'argument_one', { optional: 'arguments' }
      message.should_receive(:serialize).with(method: 'hello', args: ['argument_one', { optional: 'arguments' }])
      message.pack
    end

    it 'succesfully handles the case of no arguments present' do
      message = RabbitRPC::Message.new 'hello'
      message.should_receive(:serialize).with(method: 'hello', args: [])
      message.pack
    end
  end

  describe '.unpack' do
    it 'successfully converts the serialized message into a readable datastructure' do
      message = RabbitRPC::Message.new 'hello', 'argument_one', { optional: 'arguments' }
      RabbitRPC::Message.unpack(message.pack).should == {
        'method' => 'hello',
        'args'  => ['argument_one', { 'optional' => 'arguments' }]
      }
    end
  end

  describe '.generate_id' do
    it 'generates random values' do
      RabbitRPC::Message.generate_id.should_not be_nil
      RabbitRPC::Message.generate_id.should_not == RabbitRPC::Message.generate_id
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rabbit_rpc-0.0.2 spec/message_spec.rb