Sha256: 58f8d0c8cae81ccfb87ea6df18bf96a4025714bd8e1ac1ef0bc97b397fdd517b

Contents?: true

Size: 575 Bytes

Versions: 2

Compression:

Stored size: 575 Bytes

Contents

shared_examples_for 'Attribute#get' 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 "when a non-nil value is set" do
    before { attribute.set(object, attribute_value) }

    subject { attribute.get(object) }

    it { should eql(attribute_value) }
  end

  context "when nil is set" do
    before { attribute.set(object, nil) }

    subject { attribute.get(object) }

    it { should be(nil) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
virtus-0.0.5 spec/unit/shared/attribute/get.rb
virtus-0.0.4 spec/unit/shared/attribute/get.rb