Sha256: 25d560fa66682aaf49726df5a7be20b54528ae0e483c43c2e46df348636129a2
Contents?: true
Size: 801 Bytes
Versions: 1
Compression:
Stored size: 801 Bytes
Contents
require 'spec_helper' describe SerialTranslator::TranslationType do let(:type) { SerialTranslator::TranslationType.new } describe '#cast' do it 'works for JSON' do expect(type.cast('{"foo":"bar"}')).to eq('foo' => 'bar') end it 'works for YAML' do expect(type.cast("---\nfoo: bar")).to eq('foo' => 'bar') end it 'does nothing if already a Hash' do expect(type.cast({foo: :bar})).to eq(foo: :bar) end it 'defaults to empty hash' do expect(type.cast(nil)).to eq({}) end end describe '#serialize' do it 'converts to JSON' do expect(type.serialize({foo: :bar})).to eq('{"foo":"bar"}') end it 'leaves strings alone (to avoid double serialization)' do expect(type.serialize('foo')).to eq 'foo' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
serial_translator-2.0.0 | spec/lib/serial_translator/translation_type_spec.rb |