Sha256: f29aa89a2b56295bbd47bc48da51b342dab11ff918ccc59474f74a0902b1935d
Contents?: true
Size: 1005 Bytes
Versions: 7
Compression:
Stored size: 1005 Bytes
Contents
require 'spec_helper' describe Virtus::AttributeSet, '#[]=' do subject { object[name] = attribute } let(:attributes) { [] } let(:parent) { described_class.new } let(:object) { described_class.new(parent, attributes) } let(:name) { :name } context 'with a new attribute' do let(:attribute) { mock('Attribute', :name => name) } it { should equal(attribute) } 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) { [ mock('Attribute', :name => name) ] } let(:attribute) { mock('Duplicate', :name => name) } it { should equal(attribute) } it 'replaces the original attribute' do expect { subject }.to change { object.to_a }. from(attributes). to([ attribute ]) end end end
Version data entries
7 entries across 7 versions & 1 rubygems