Sha256: 9fc4ed32166c66e0c123654d290a470b1142ca7d66581c10d101a75bcaaa9750

Contents?: true

Size: 684 Bytes

Versions: 2

Compression:

Stored size: 684 Bytes

Contents

require 'spec_helper'

describe Virtus::ValueObject, '.attribute' do
  subject { object.attribute(name, type) }

  let(:object)    { Class.new { include Virtus::ValueObject } }
  let(:name)      { :latitude                                 }
  let(:type)      { Float                                     }
  let(:attribute) { object.attribute_set[name]                }

  it { should be(object) }

  it 'adds the attribute to the equalizer' do
    object.new.inspect.should_not match(/\b#{name}=\b/)
    subject
    object.new.inspect.should match(/\b#{name}=\b/)
  end

  it 'sets the writer to be private' do
    subject
    attribute.options[:writer].should be(:private)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
virtus-0.5.1 spec/unit/virtus/value_object/class_methods/attribute_spec.rb
virtus-0.5.0 spec/unit/virtus/value_object/class_methods/attribute_spec.rb