Sha256: 3f423da4e8507e2137d7e494ae022059363a229fc33cb539828ef0a92fe36793

Contents?: true

Size: 923 Bytes

Versions: 12

Compression:

Stored size: 923 Bytes

Contents

require 'spec_helper'

describe Virtus::AttributeSet, '#merge' do
  subject { object.merge(other) }

  let(:parent) { described_class.new }
  let(:object) { described_class.new(parent, attributes) }
  let(:name)   { :name }
  let(:other)  { [attribute] }

  context 'with a new attribute' do
    let(:attributes) { [] }
    let(:attribute)  { Virtus::Attribute.build(String, :name => name) }

    it { should equal(object) }

    it 'adds an attribute' do
      expect { subject }.to change { object.to_a }.from(attributes).to([attribute])
    end
  end

  context 'with a duplicate attribute' do
    let(:attributes) { [Virtus::Attribute.build(String, :name => name)] }
    let(:attribute)  { Virtus::Attribute.build(String, :name => name) }

    it { should equal(object) }

    it 'replaces the original attribute' do
      expect { subject }.to change { object.to_a }.from(attributes).to([attribute])
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
virtus-1.0.3 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.2 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.1 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.0 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.0.rc2 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.0.rc1 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.0.beta8 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.0.beta7 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.0.beta6 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.0.beta5 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.0.beta4 spec/unit/virtus/attribute_set/merge_spec.rb
virtus-1.0.0.beta3 spec/unit/virtus/attribute_set/merge_spec.rb