Sha256: 5fffe7006f398e1b21c370dc858933e204d0c57b3576c022a8aaa61554387bfb
Contents?: true
Size: 1.05 KB
Versions: 2
Compression:
Stored size: 1.05 KB
Contents
shared_examples_for 'Attribute#set' do let(:model) do Class.new { include Virtus } end let(:attribute) do model.attribute(attribute_name, described_class).attributes[attribute_name] end let(:object) do model.new end context "with nil" do subject { attribute.set(object, nil) } it "doesn't set the ivar" do subject object.instance_variable_defined?(attribute.instance_variable_name).should be(false) end it "returns nil" do subject.should be(nil) end end context "with a primitive value" do before { attribute.set(object, attribute_value) } it "sets the value in an ivar" do object.instance_variable_get(attribute.instance_variable_name).should eql(attribute_value) end end context "with a non-primitive value" do before { attribute.set(object, attribute_value_other) } it "sets the value in an ivar converted to the primitive type" do object.instance_variable_get(attribute.instance_variable_name).should be_kind_of(described_class.primitive) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
virtus-0.0.5 | spec/unit/shared/attribute/set.rb |
virtus-0.0.4 | spec/unit/shared/attribute/set.rb |