Sha256: e928abd2bcef0b4001a6d51a0c911f727dbb58c3b8f6475688af51c4c5538838

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

require 'rabbit_rpc'

describe RabbitRPC::MessageParser do
  let(:message) { {'method' => 'UserService.create', 'args' => [1, 2, 3] } }
  let(:one_way) { {'method' => 'AuthService.one_way_delete', 'args' => [1, 2, 3] } }

  describe '#one_way?' do
    it 'determines if the method begins with the one_way prefix' do
      example_one = RabbitRPC::MessageParser.new(message)
      example_one.parse
      example_one.one_way?.should be_false

      example_two = RabbitRPC::MessageParser.new(one_way)
      example_two.parse
      example_two.one_way?.should be_true
    end

    context 'parser has not executed' do
      it 'determines if the method begins with the one_way prefix' do
        RabbitRPC::MessageParser.new(message).one_way?.should be_false
        RabbitRPC::MessageParser.new(one_way).one_way?.should be_true
      end
    end
  end

  describe '#parse' do
    it 'correctly identifies the name of the Service' do
      example_one = RabbitRPC::MessageParser.new(message)
      example_one.parse
      example_one.service_name.should == 'UserService'

      example_two = RabbitRPC::MessageParser.new(one_way)
      example_two.parse
      example_two.service_name.should == 'AuthService'
    end

    it 'correctly identifies the name of the method' do
      example_one = RabbitRPC::MessageParser.new(message)
      example_one.parse
      example_one.method_name.should == 'create'

      example_two = RabbitRPC::MessageParser.new(one_way)
      example_two.parse
      example_two.method_name.should == 'one_way_delete'
    end

    # Test case for message class and hash
    # Invalid format?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rabbit_rpc-0.0.2 spec/message_parser_spec.rb