Sha256: 0841f84fa7df60a7bd64c2616b9cb8c8ce0c787e12a6b29a8dd5c29e1e7fd568
Contents?: true
Size: 1.11 KB
Versions: 14
Compression:
Stored size: 1.11 KB
Contents
# frozen_string_literal: truie describe Arstotzka::Wrapper do subject(:wrapper) { described_class.new(klass: klass, type: type) } let(:type) { nil } let(:klass) { nil } describe 'yard' do describe '#wrap' do context 'when klass is defined' do let(:klass) { Person } let(:value) { 'john' } it 'wraps value with the klass' do expect(wrapper.wrap(value)).to eq(Person.new(value)) end end context 'when type is defined' do let(:type) { :integer } let(:value) { %w[10 20 30] } it 'converts value to type' do expect(wrapper.wrap(value)).to eq([10, 20, 30]) end end context 'when type and class is defined' do let(:type) { :string } let(:klass) { Request } let(:value) { { 'key' => 'value' } } let(:request) { wrapper.wrap(value) } it 'returns a wrapped object' do expect(request).to be_a(Request) end it 'casts before wrapping' do expect(request.payload).to eq('{"key"=>"value"}') end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems