Sha256: 6ec7049276f382727921cb172afecf3029a359cc6c72f69574dc58852aff0e83

Contents?: true

Size: 759 Bytes

Versions: 5

Compression:

Stored size: 759 Bytes

Contents

require 'spec_helper'

describe Anima::Attribute, '#load' do
  let(:object) { described_class.new(:foo) }

  subject { object.load(target, attribute_hash) }

  let(:target) { Object.new }

  let(:value) { mock('Value') }

  context 'when attribute hash contains key' do
    let(:attribute_hash) { { :foo => value } }

    it 'should set value as instance variable' do
      subject
      target.instance_variable_get(:@foo).should be(value)
    end

    it_should_behave_like 'a command method'

  end

  context 'when attribute hash does not contain key' do
    let(:attribute_hash) { {} }

    it 'should raise error' do
      expect { subject }.to raise_error(Anima::Error::Missing, Anima::Error::Missing.new(target.class, :foo).message)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
anima-0.0.6 spec/unit/anima/attribute/load_spec.rb
anima-0.0.5 spec/unit/anima/attribute/load_spec.rb
anima-0.0.4 spec/unit/anima/attribute/load_spec.rb
anima-0.0.3 spec/unit/anima/attribute/load_spec.rb
anima-0.0.2 spec/unit/anima/attribute/load_spec.rb