File: attribute_spec.rb

package info (click to toggle)
ruby-unparser 0.6.13-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 936 kB
  • sloc: ruby: 7,691; sh: 6; makefile: 4
file content (62 lines) | stat: -rw-r--r-- 1,341 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
describe Unparser::Anima::Attribute do
  let(:object) { described_class.new(:foo) }

  describe '#get' do
    subject { object.get(target) }

    let(:target_class) do
      Class.new do
        attr_reader :foo

        def initialize(foo)
          @foo = foo
        end
      end
    end

    let(:target) { target_class.new(value) }
    let(:value) { double('Value') }

    it 'should return value' do
      should be(value)
    end
  end

  describe '#load' do
    subject { object.load(target, attribute_hash) }

    let(:target)         { Object.new      }
    let(:value)          { double('Value') }
    let(:attribute_hash) { { foo: value }  }

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

    it_should_behave_like 'a command method'
  end

  describe '#instance_variable_name' do
    subject { object.instance_variable_name }

    it { should be(:@foo) }

    it_should_behave_like 'an idempotent method'
  end

  describe '#set' do
    subject { object.set(target, value) }

    let(:target) { Object.new }

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

    it_should_behave_like 'a command method'

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