Sha256: 072b16f3f6cc47d81bd0cfa568ad2d38b60e9f5ab24ec647c630299a207a426b
Contents?: true
Size: 1.19 KB
Versions: 10
Compression:
Stored size: 1.19 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', :public_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(:public_send).with(coercion_method, value) subject end end
Version data entries
10 entries across 10 versions & 2 rubygems