Sha256: 6a5f05f1330d7dedcbfa36629c7a46c7845fe92ea421f780da7e55e415b32b0a
Contents?: true
Size: 996 Bytes
Versions: 7
Compression:
Stored size: 996 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 { is_expected.to 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 { is_expected.to equal(object) } it "replaces the original attribute object" do expect { subject }.to change { object.to_a.map(&:__id__) }. from(attributes.map(&:__id__)). to([attribute.__id__]) end end end
Version data entries
7 entries across 7 versions & 3 rubygems