Sha256: e04d1d05ba42e34a7764ec89fec187f39c2f00919daddb93bb899b4b2b99ae88

Contents?: true

Size: 833 Bytes

Versions: 18

Compression:

Stored size: 833 Bytes

Contents

require 'spec_helper'
require 'mercury/wire_serializer'

describe Mercury::WireSerializer do
  subject {Mercury::WireSerializer.new}
  describe '#write' do
    it 'writes a string hash as JSON' do
      expect(subject.write({'a' => 1})).to eql '{"a":1}'
    end
    it 'writes a symbol hash as JSON' do
      expect(subject.write({a: 1})).to eql '{"a":1}'
    end
    it 'writes a struct as JSON' do
      Foo = Struct.new(:a)
      expect(subject.write(Foo.new(1))).to eql '{"a":1}'
    end
    it 'writes a string literally' do
      expect(subject.write('asdf')).to eql 'asdf'
    end
  end
  describe '#read' do
    it 'reads JSON as a string hash' do
      expect(subject.read('{"a":1}')).to eql('a' => 1)
    end
    it 'reads unparseable JSON as a string' do
      expect(subject.read('asdf')).to eql 'asdf'
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mercury_amqp-0.10.0 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.9.0 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.8.0 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.7.0 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.6.1 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.6.0 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.5.0 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.4.0 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.3.0 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.2.0 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.1.9 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.1.7 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.1.6 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.1.5 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.1.4 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.1.3 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.1.2 spec/lib/mercury/wire_serializer_spec.rb
mercury_amqp-0.1.0 spec/lib/mercury/wire_serializer_spec.rb