Sha256: 402ef85964be0f4ad5925491d9b94a4f70fc9c8cca524afc19a0a9e70e341478

Contents?: true

Size: 649 Bytes

Versions: 8

Compression:

Stored size: 649 Bytes

Contents

require 'spec_helper'

RSpec.describe Yaks::Serializer do
  after do
    Yaks::Serializer.instance_variable_set("@serializers", nil)
  end

  it 'allows registering serializers' do
    Yaks::Serializer.register(:some_format, :some_serializer)
    expect(Yaks::Serializer.all[:some_format]).to equal :some_serializer
  end

  it 'should by default have a serializer for JSON' do
    expect(Yaks::Serializer.all[:json].call([1,2,3], {})).to eql "[\n  1,\n  2,\n  3\n]"
  end

  it 'should warn when registering a key again' do
    expect { Yaks::Serializer.register(:json, :foo) }.to raise_exception /Serializer for json already registered/
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
yaks-0.7.7 spec/unit/yaks/serializer_spec.rb
yaks-0.7.6 spec/unit/yaks/serializer_spec.rb
yaks-0.7.5 spec/unit/yaks/serializer_spec.rb
yaks-0.7.4 spec/unit/yaks/serializer_spec.rb
yaks-0.7.3 spec/unit/yaks/serializer_spec.rb
yaks-0.7.2 spec/unit/yaks/serializer_spec.rb
yaks-0.7.1 spec/unit/yaks/serializer_spec.rb
yaks-0.7.0 spec/unit/yaks/serializer_spec.rb