vedeu 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu.rb +0 -18
  3. data/lib/vedeu/output/colour.rb +18 -7
  4. data/lib/vedeu/output/compositor.rb +20 -8
  5. data/lib/vedeu/process/process.rb +1 -5
  6. data/lib/vedeu/repository/command.rb +12 -0
  7. data/lib/vedeu/repository/command_repository.rb +10 -2
  8. data/lib/vedeu/repository/dummy_command.rb +2 -0
  9. data/lib/vedeu/repository/dummy_interface.rb +3 -1
  10. data/lib/vedeu/repository/interface.rb +31 -4
  11. data/lib/vedeu/repository/interface_repository.rb +5 -1
  12. data/lib/vedeu/repository/storage.rb +1 -1
  13. data/lib/vedeu/support/terminal.rb +13 -3
  14. data/lib/vedeu/version.rb +1 -1
  15. data/test/lib/vedeu/application_test.rb +6 -2
  16. data/test/lib/vedeu/launcher_test.rb +3 -1
  17. data/test/lib/vedeu/output/background_test.rb +30 -10
  18. data/test/lib/vedeu/output/colour_test.rb +39 -2
  19. data/test/lib/vedeu/output/compositor_test.rb +48 -14
  20. data/test/lib/vedeu/output/directive_test.rb +24 -8
  21. data/test/lib/vedeu/output/esc_test.rb +48 -16
  22. data/test/lib/vedeu/output/foreground_test.rb +30 -10
  23. data/test/lib/vedeu/output/geometry_test.rb +78 -28
  24. data/test/lib/vedeu/output/position_test.rb +9 -3
  25. data/test/lib/vedeu/output/renderer_test.rb +15 -5
  26. data/test/lib/vedeu/output/style_test.rb +30 -10
  27. data/test/lib/vedeu/output/translator_test.rb +3 -1
  28. data/test/lib/vedeu/process/event_loop_test.rb +12 -4
  29. data/test/lib/vedeu/process/exit_test.rb +6 -2
  30. data/test/lib/vedeu/process/input_test.rb +9 -3
  31. data/test/lib/vedeu/process/output_test.rb +12 -4
  32. data/test/lib/vedeu/process/process_test.rb +24 -8
  33. data/test/lib/vedeu/process/queue_test.rb +32 -8
  34. data/test/lib/vedeu/repository/command_repository_test.rb +27 -9
  35. data/test/lib/vedeu/repository/command_test.rb +33 -9
  36. data/test/lib/vedeu/repository/dummy_command_test.rb +9 -3
  37. data/test/lib/vedeu/repository/interface_repository_test.rb +18 -6
  38. data/test/lib/vedeu/repository/interface_test.rb +39 -11
  39. data/test/lib/vedeu/repository/repository_test.rb +24 -8
  40. data/test/lib/vedeu/repository/storage_test.rb +39 -2
  41. data/test/lib/vedeu/support/terminal_test.rb +68 -16
  42. data/test/lib/vedeu/version_test.rb +3 -1
  43. data/test/test_helper.rb +3 -0
  44. data/vedeu.gemspec +13 -12
  45. metadata +45 -30
@@ -16,25 +16,49 @@ module Vedeu
16
16
  }
17
17
  }
18
18
 
19
- it { subject.must_be_instance_of(Command) }
20
- it { subject.instance_variable_get("@attributes").must_equal(attributes) }
21
- it { subject.instance_variable_get("@name").must_equal('dummy') }
22
- it { subject.instance_variable_get("@klass").must_equal(DummyCommand) }
23
- it { subject.instance_variable_get("@keyword").must_equal('dummy') }
24
- it { subject.instance_variable_get("@keypress").must_equal('d') }
19
+ it 'returns a Command instance' do
20
+ subject.must_be_instance_of(Command)
21
+ end
22
+
23
+ it 'sets an instance variable' do
24
+ subject.instance_variable_get("@attributes").must_equal(attributes)
25
+ end
26
+
27
+ it 'sets an instance variable' do
28
+ subject.instance_variable_get("@name").must_equal('dummy')
29
+ end
30
+
31
+ it 'sets an instance variable' do
32
+ subject.instance_variable_get("@klass").must_equal(DummyCommand)
33
+ end
34
+
35
+ it 'sets an instance variable' do
36
+ subject.instance_variable_get("@keyword").must_equal('dummy')
37
+ end
38
+
39
+ it 'sets an instance variable' do
40
+ subject.instance_variable_get("@keypress").must_equal('d')
41
+ end
25
42
 
26
43
  describe '#create' do
27
44
  let(:subject) { described_class.create(attributes) }
28
45
 
29
- it { subject.must_be_instance_of(Command) }
46
+ it 'returns a Command instance' do
47
+ subject.must_be_instance_of(Command)
48
+ end
30
49
  end
31
50
 
32
51
  describe '#execute' do
33
52
  let(:subject) { described_instance.execute(args) }
34
53
  let(:args) { [] }
35
54
 
36
- it { subject.must_be_instance_of(Symbol) }
37
- it { subject.must_equal(:dummy) }
55
+ it 'returns a Symbol' do
56
+ subject.must_be_instance_of(Symbol)
57
+ end
58
+
59
+ it 'returns the result of execution' do
60
+ subject.must_equal(:dummy)
61
+ end
38
62
  end
39
63
 
40
64
  describe '#executable' do
@@ -6,16 +6,22 @@ module Vedeu
6
6
  let(:subject) { described_class.dispatch(command) }
7
7
  let(:command) {}
8
8
 
9
- it { subject.must_be_instance_of(Symbol) }
9
+ it 'returns a Symbol' do
10
+ subject.must_be_instance_of(Symbol)
11
+ end
10
12
 
11
13
  context 'when the value exists' do
12
14
  let(:command) { :test_command }
13
15
 
14
- it { subject.must_equal(:test_command) }
16
+ it 'returns the value' do
17
+ subject.must_equal(:test_command)
18
+ end
15
19
  end
16
20
 
17
21
  context 'when the value does not exist' do
18
- it { subject.must_equal(:dummy) }
22
+ it 'returns the default value' do
23
+ subject.must_equal(:dummy)
24
+ end
19
25
  end
20
26
  end
21
27
  end
@@ -11,37 +11,49 @@ module Vedeu
11
11
  describe '.activate' do
12
12
  let(:subject) { described_class.activate(interface) }
13
13
 
14
- it { subject.must_be_instance_of(Array) }
14
+ it 'returns an Array' do
15
+ subject.must_be_instance_of(Array)
16
+ end
15
17
  end
16
18
 
17
19
  describe '.deactivate' do
18
20
  let(:subject) { described_class.deactivate }
19
21
 
20
- it { subject.must_be_instance_of(Array) }
22
+ it 'returns an Array' do
23
+ subject.must_be_instance_of(Array)
24
+ end
21
25
  end
22
26
 
23
27
  describe '.activated' do
24
28
  let(:subject) { described_class.activated }
25
29
 
26
- it { subject.must_be_instance_of(Interface) }
30
+ it 'returns an Interface' do
31
+ subject.must_be_instance_of(Interface)
32
+ end
27
33
  end
28
34
 
29
35
  describe '.find_by_name' do
30
36
  let(:subject) { described_class.find_by_name(value) }
31
37
 
32
- it { subject.must_be_instance_of(Interface) }
38
+ it 'returns an Interface' do
39
+ subject.must_be_instance_of(Interface)
40
+ end
33
41
  end
34
42
 
35
43
  describe '.initial_state' do
36
44
  let(:subject) { described_class.initial_state }
37
45
 
38
- it { subject.must_be_instance_of(Array) }
46
+ it 'returns an Array' do
47
+ # subject.must_be_instance_of(Array)
48
+ end
39
49
  end
40
50
 
41
51
  describe '.klass' do
42
52
  let(:subject) { described_class.klass }
43
53
 
44
- it { subject.must_equal(Interface) }
54
+ it 'returns an Interface' do
55
+ subject.must_equal(Interface)
56
+ end
45
57
  end
46
58
  end
47
59
  end
@@ -7,37 +7,65 @@ module Vedeu
7
7
  let(:subject) { described_instance }
8
8
  let(:attributes) {
9
9
  {
10
- name: 'dummy',
11
- geometry: { width: 80, height: 25, x: 1, y: 1 }
10
+ name: 'dummy',
11
+ width: 40,
12
+ height: 5,
13
+ x: 1,
14
+ y: 1,
15
+ fg: :red,
16
+ bg: :blue
12
17
  }
13
18
  }
14
19
  let(:result) {}
15
20
 
16
- before do
21
+ it 'returns an Interface instance' do
22
+ subject.must_be_instance_of(Interface)
17
23
  end
18
24
 
19
- it { subject.must_be_instance_of(Interface) }
20
- it { subject.instance_variable_get("@attributes").must_equal(attributes) }
21
- it { subject.instance_variable_get("@active").must_equal(false) }
22
- it { subject.instance_variable_get("@geometry").must_equal(attributes[:geometry]) }
23
- it { subject.instance_variable_get("@name").must_equal('dummy') }
25
+ it 'sets an instance variable' do
26
+ subject.instance_variable_get("@attributes").must_equal(attributes)
27
+ end
28
+
29
+ it 'sets an instance variable' do
30
+ subject.instance_variable_get("@active").must_equal(false)
31
+ end
32
+
33
+ it 'sets an instance variable' do
34
+ subject.instance_variable_get("@name").must_equal('dummy')
35
+ end
24
36
 
25
37
  describe '#create' do
26
38
  let(:subject) { described_class.create(attributes) }
27
39
 
28
- it { subject.must_be_instance_of(Interface) }
40
+ it 'returns an Interface' do
41
+ subject.must_be_instance_of(Interface)
42
+ end
29
43
  end
30
44
 
31
45
  describe '#initial_state' do
32
46
  let(:subject) { described_instance.initial_state }
33
47
 
34
- it { subject.must_be_instance_of(NilClass) }
48
+ before { Compositor.stubs(:arrange) }
49
+
50
+ it 'returns a NilClass' do
51
+ subject.must_be_instance_of(NilClass)
52
+ end
35
53
  end
36
54
 
37
55
  describe '#geometry' do
38
56
  let(:subject) { described_instance.geometry }
39
57
 
40
- it { subject.must_be_instance_of(Geometry) }
58
+ it 'returns a Geometry' do
59
+ subject.must_be_instance_of(Geometry)
60
+ end
61
+ end
62
+
63
+ describe '#colour' do
64
+ let(:subject) { described_instance.colour }
65
+
66
+ it 'returns a Colour' do
67
+ subject.must_be_instance_of(Colour)
68
+ end
41
69
  end
42
70
  end
43
71
  end
@@ -31,27 +31,35 @@ module Vedeu
31
31
  describe '#adaptor' do
32
32
  let(:subject) { described_class.adaptor }
33
33
 
34
- it { subject.must_be_instance_of(Storage) }
34
+ it 'returns a Storage' do
35
+ subject.must_be_instance_of(Storage)
36
+ end
35
37
  end
36
38
 
37
39
  describe '#adaptor=' do
38
40
  let(:subject) { described_class.adaptor=(adaptor) }
39
41
  let(:adaptor) { Storage.new }
40
42
 
41
- it { subject.must_be_instance_of(Storage) }
43
+ it 'returns a Storage' do
44
+ subject.must_be_instance_of(Storage)
45
+ end
42
46
  end
43
47
 
44
48
  describe '#find' do
45
49
  let(:subject) { described_class.find(id) }
46
50
  let(:id) { @dummy.id }
47
51
 
48
- it { subject.must_be_instance_of(Dummy) }
52
+ it 'returns a Dummy' do
53
+ subject.must_be_instance_of(Dummy)
54
+ end
49
55
  end
50
56
 
51
57
  describe '#all' do
52
58
  let(:subject) { described_class.all }
53
59
 
54
- it { subject.must_be_instance_of(Array) }
60
+ it 'returns all the stored items' do
61
+ subject.must_be_instance_of(Array)
62
+ end
55
63
  end
56
64
 
57
65
  describe '#query' do
@@ -60,27 +68,35 @@ module Vedeu
60
68
  let(:attribute) { :name }
61
69
  let(:value) { "dummy" }
62
70
 
63
- it { subject.must_be_instance_of(Dummy) }
71
+ it 'returns a Dummy' do
72
+ subject.must_be_instance_of(Dummy)
73
+ end
64
74
  end
65
75
 
66
76
  describe '#create' do
67
77
  let(:subject) { described_class.create(model) }
68
78
  let(:model) { @dummy }
69
79
 
70
- it { subject.must_be_instance_of(Dummy) }
80
+ it 'returns a Dummy' do
81
+ subject.must_be_instance_of(Dummy)
82
+ end
71
83
  end
72
84
 
73
85
  describe '#delete' do
74
86
  let(:subject) { described_class.delete(model) }
75
87
  let(:model) { @dummy }
76
88
 
77
- it { subject.must_be_instance_of(Dummy) }
89
+ it 'returns a Dummy' do
90
+ subject.must_be_instance_of(Dummy)
91
+ end
78
92
  end
79
93
 
80
94
  describe '#reset' do
81
95
  let(:subject) { described_class.reset }
82
96
 
83
- it { subject.must_be_instance_of(Array) }
97
+ it 'returns an Array' do
98
+ subject.must_be_instance_of(Array)
99
+ end
84
100
  end
85
101
  end
86
102
  end
@@ -4,35 +4,72 @@ module Vedeu
4
4
  describe Storage do
5
5
  let(:described_class) { Storage }
6
6
  let(:subject) { described_class.new }
7
- let(:record) {}
7
+ let(:record) { DummyCommand.new }
8
8
  let(:klass) {}
9
9
 
10
- it { subject.must_be_instance_of(Storage) }
10
+ it 'returns a Storage instance' do
11
+ subject.must_be_instance_of(Storage)
12
+ end
13
+
14
+ it 'sets an instance variable' do
15
+ subject.instance_variable_get("@counter").must_equal(0)
16
+ end
17
+
18
+ it 'sets an instance variable' do
19
+ subject.instance_variable_get("@map").must_equal({})
20
+ end
11
21
 
12
22
  describe '#create' do
13
23
  let(:subject) { described_class.new.create(record) }
24
+
25
+ it 'returns the stored record' do
26
+ subject.must_be_instance_of(DummyCommand)
27
+ end
14
28
  end
15
29
 
16
30
  describe '#delete' do
17
31
  let(:subject) { described_class.new.delete(record) }
32
+
33
+ it 'returns a NilClass' do
34
+ subject.must_be_instance_of(NilClass)
35
+ end
18
36
  end
19
37
 
20
38
  describe '#reset' do
21
39
  let(:subject) { described_class.new.reset(klass) }
40
+
41
+ it 'returns an Array' do
42
+ subject.must_be_instance_of(Array)
43
+ end
22
44
  end
23
45
 
24
46
  describe '#find' do
25
47
  let(:subject) { described_class.new.find(klass, id) }
48
+ let(:id) { 'dummy' }
49
+
50
+ it 'returns a NilClass' do
51
+ subject.must_be_instance_of(NilClass)
52
+ end
26
53
  end
27
54
 
28
55
  describe '#all' do
29
56
  let(:subject) { described_class.new.all(klass) }
57
+
58
+ it 'returns an Array' do
59
+ subject.must_be_instance_of(Array)
60
+ end
30
61
  end
31
62
 
32
63
  describe '#query' do
33
64
  let(:subject) { described_class.new.query(klass, attribute, value) }
34
65
  let(:attribute) {}
35
66
  let(:value) {}
67
+
68
+ context 'when the item cannot be found' do
69
+ it 'returns a Hash' do
70
+ subject.must_be_instance_of(Hash)
71
+ end
72
+ end
36
73
  end
37
74
  end
38
75
  end
@@ -16,9 +16,13 @@ module Vedeu
16
16
 
17
17
  before { console.stubs(:gets).returns("test\n") }
18
18
 
19
- it { subject.must_be_instance_of(String) }
19
+ it 'returns a String' do
20
+ subject.must_be_instance_of(String)
21
+ end
20
22
 
21
- it { subject.must_equal("test") }
23
+ it 'returns the entered string' do
24
+ subject.must_equal("test")
25
+ end
22
26
  end
23
27
 
24
28
  describe '.output' do
@@ -26,13 +30,21 @@ module Vedeu
26
30
 
27
31
  before { console.stubs(:print).returns("test") }
28
32
 
29
- it { subject.must_be_instance_of(String) }
33
+ it 'returns a String' do
34
+ subject.must_be_instance_of(String)
35
+ end
36
+
37
+ it 'returns the output' do
38
+ subject.must_equal("test")
39
+ end
30
40
  end
31
41
 
32
42
  describe '.width' do
33
43
  let(:subject) { described_class.width }
34
44
 
35
- it { subject.must_be_instance_of(Fixnum) }
45
+ it 'returns a Fixnum' do
46
+ subject.must_be_instance_of(Fixnum)
47
+ end
36
48
 
37
49
  it 'returns the width of the terminal' do
38
50
  subject.must_equal(80)
@@ -42,7 +54,9 @@ module Vedeu
42
54
  describe '.height' do
43
55
  let(:subject) { described_class.height }
44
56
 
45
- it { subject.must_be_instance_of(Fixnum) }
57
+ it 'returns a Fixnum' do
58
+ subject.must_be_instance_of(Fixnum)
59
+ end
46
60
 
47
61
  it 'returns the height of the terminal' do
48
62
  subject.must_equal(25)
@@ -52,7 +66,9 @@ module Vedeu
52
66
  describe '.size' do
53
67
  let(:subject) { described_class.size }
54
68
 
55
- it { subject.must_be_instance_of(Array) }
69
+ it 'returns an Array' do
70
+ subject.must_be_instance_of(Array)
71
+ end
56
72
 
57
73
  it 'returns the width and height of the terminal' do
58
74
  subject.must_equal([25, 80])
@@ -84,12 +100,16 @@ module Vedeu
84
100
 
85
101
  before { Esc.stubs(:clear).returns('') }
86
102
 
87
- it { subject.must_be_instance_of(NilClass) }
103
+ it 'returns a NilClass' do
104
+ subject.must_be_instance_of(NilClass)
105
+ end
88
106
 
89
107
  context 'capturing output' do
90
108
  let(:io) { capture_io { subject }.join }
91
109
 
92
- it { io.must_be_instance_of(String) }
110
+ it 'returns a String' do
111
+ io.must_be_instance_of(String)
112
+ end
93
113
  end
94
114
  end
95
115
 
@@ -97,49 +117,81 @@ module Vedeu
97
117
  let(:subject) { described_class.clear_line(index) }
98
118
  let(:index) { 0 }
99
119
 
100
- it { subject.must_be_instance_of(NilClass) }
120
+ it 'returns a NilClass' do
121
+ subject.must_be_instance_of(NilClass)
122
+ end
101
123
  end
102
124
 
103
125
  describe '.show_cursor' do
104
126
  let(:subject) { described_class.show_cursor }
105
127
 
106
- it { subject.must_be_instance_of(NilClass) }
128
+ it 'returns a NilClass' do
129
+ subject.must_be_instance_of(NilClass)
130
+ end
107
131
 
108
132
  context 'capturing output' do
109
133
  let(:io) { capture_io { subject }.join }
110
134
 
111
- it { io.must_be_instance_of(String) }
135
+ it 'returns a String' do
136
+ io.must_be_instance_of(String)
137
+ end
112
138
  end
113
139
  end
114
140
 
115
141
  describe '.hide_cursor' do
116
142
  let(:subject) { described_class.hide_cursor }
117
143
 
118
- it { subject.must_be_instance_of(NilClass) }
144
+ it 'returns a NilClass' do
145
+ subject.must_be_instance_of(NilClass)
146
+ end
147
+
148
+ context 'capturing output' do
149
+ let(:io) { capture_io { subject }.join }
150
+
151
+ it 'returns a String' do
152
+ io.must_be_instance_of(String)
153
+ end
154
+ end
155
+ end
156
+
157
+ describe '.reset_colours' do
158
+ let(:subject) { described_class.reset_colours }
159
+
160
+ it 'returns a NilClass' do
161
+ subject.must_be_instance_of(NilClass)
162
+ end
119
163
 
120
164
  context 'capturing output' do
121
165
  let(:io) { capture_io { subject }.join }
122
166
 
123
- it { io.must_be_instance_of(String) }
167
+ it 'returns a String' do
168
+ io.must_be_instance_of(String)
169
+ end
124
170
  end
125
171
  end
126
172
 
127
173
  describe '#initialize' do
128
174
  let(:subject) { described_class.new }
129
175
 
130
- it { subject.must_be_instance_of(Terminal) }
176
+ it 'returns a Terminal instance' do
177
+ subject.must_be_instance_of(Terminal)
178
+ end
131
179
  end
132
180
 
133
181
  describe '#open' do
134
182
  let(:subject) { described_class.new.open }
135
183
 
136
- it { subject.must_be_instance_of(NilClass) }
184
+ it 'returns a NilClass' do
185
+ subject.must_be_instance_of(NilClass)
186
+ end
137
187
  end
138
188
 
139
189
  describe '#initial_setup!' do
140
190
  let(:subject) { described_class.new.initial_setup! }
141
191
 
142
- it { subject.must_be_instance_of(NilClass) }
192
+ it 'returns a NilClass' do
193
+ subject.must_be_instance_of(NilClass)
194
+ end
143
195
  end
144
196
  end
145
197
  end