Sha256: b8e0f0629f69e7877eda5413bb45f6308d1712235889d6d058a92e50bc68eaac
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' describe Virtus::Attribute::DefaultValue, '#evaluate' do subject { object.evaluate(instance) } let(:object) { described_class.new(attribute, value) } let(:attribute) { mock('attribute') } let(:value) { mock('value') } let(:instance) { mock('instance') } context 'when the value is callable' do let(:response) { stub('response') } before do value.stub(:call => response) end it { should be(response) } it 'calls the value with the instance and attribute' do value.should_receive(:call).with(instance, attribute) subject end end context 'when the value is cloneable' do let(:clone) { stub('clone') } before do value.stub(:clone => clone) end it { should be(clone) } it 'clones the value' do value.should_receive(:clone).with(no_args) subject end end # smallest number that is Bignum across major ruby impls bignum = 0x7fffffffffffffff + 1 [ nil, true, false, 0, 0.0, bignum, :symbol ].each do |value| context "when the value is #{value.inspect} (#{value.class})" do let(:value) { value } it { should be(value) } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
virtus-0.2.0 | spec/unit/virtus/attribute/default_value/evaluate_spec.rb |
virtus-0.1.0 | spec/unit/virtus/attribute/default_value/evaluate_spec.rb |