Sha256: dda6562f1b12ac0e420bb2365a69f5138136c732b33c5b72ba291f01f3715921
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
require 'spec_helper' describe Virtus::Attribute, '#coerce' do subject { object.coerce(value) } let(:object) { described_class.new(:name, options) } let(:options) { { :primitive => primitive, :coercion_method => coercion_method } } let(:primitive) { stub('primitive') } let(:coercion_method) { stub('coercion_method') } let(:value) { mock('value', :class => value_class) } let(:value_class) { stub('value_class') } let(:coercer) { mock('coercer', :send => coerced) } let(:coerced) { stub('coerced') } before do Virtus::Coercion.stub(:[]).with(value_class).and_return(coercer) end it { should be(coerced) } it 'asks for a coercer object' do Virtus::Coercion.should_receive(:[]).with(value_class) subject end it 'asks the coercer to coerce the value' do coercer.should_receive(:send).with(coercion_method, value) subject end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
virtus-0.3.0 | spec/unit/virtus/attribute/coerce_spec.rb |
virtus-0.2.0 | spec/unit/virtus/attribute/coerce_spec.rb |
virtus-0.1.0 | spec/unit/virtus/attribute/coerce_spec.rb |