Sha256: b0706c9c40e07413ef7f5362068ddbff76a9b6be32b22aaf29a1f1c8ffb48603
Contents?: true
Size: 718 Bytes
Versions: 6
Compression:
Stored size: 718 Bytes
Contents
require 'spec_helper' describe Virtus::Attribute::EmbeddedValue::FromStruct, '#coerce' do subject { object.coerce(value) } let(:primitive) { Struct.new(:x, :y) } let(:object) do described_class.new(:name, :primitive => primitive) end context 'when the value is nil' do let(:value) { nil } it { should be_nil } end context 'when the value is a primitive instance' do let(:value) { primitive.new } it { should be(value) } end context 'when the value is an array' do let(:value) { [ 1 ,2 ] } let(:instance) { mock('instance') } before do primitive.should_receive(:new).with(*value).and_return(instance) end it { should be(instance) } end end
Version data entries
6 entries across 6 versions & 2 rubygems