Sha256: c02ba67f9a931a266aa9498733c9410f0b51807ec8c53b7b862ed947418574ad
Contents?: true
Size: 722 Bytes
Versions: 6
Compression:
Stored size: 722 Bytes
Contents
require 'spec_helper' describe Virtus::Attribute::EmbeddedValue::FromOpenStruct, '#coerce' do subject { object.coerce(value) } let(:primitive) { OpenStruct } 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 a hash' do let(:value) { Hash[:foo => 'bar'] } 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