vedeu 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/application/controller.rb +2 -2
  3. data/lib/vedeu/cursor/refresh_cursor.rb +1 -1
  4. data/lib/vedeu/dsl/presentation.rb +3 -3
  5. data/lib/vedeu/dsl/use.rb +0 -34
  6. data/lib/vedeu/events/event.rb +2 -2
  7. data/lib/vedeu/events/trigger.rb +1 -1
  8. data/lib/vedeu/geometry/area.rb +1 -1
  9. data/lib/vedeu/geometry/dimension.rb +2 -2
  10. data/lib/vedeu/input/input.rb +1 -1
  11. data/lib/vedeu/log/log.rb +5 -3
  12. data/lib/vedeu/models/focus.rb +1 -1
  13. data/lib/vedeu/models/interfaces.rb +1 -1
  14. data/lib/vedeu/models/toggleable.rb +5 -5
  15. data/lib/vedeu/null/interface.rb +1 -8
  16. data/lib/vedeu/null/view.rb +1 -8
  17. data/lib/vedeu/output/refresh_group.rb +1 -1
  18. data/lib/vedeu/output/renderers/json.rb +1 -1
  19. data/lib/vedeu/repositories/model.rb +1 -1
  20. data/lib/vedeu/repositories/registerable.rb +1 -1
  21. data/lib/vedeu/templating/view_template.rb +3 -3
  22. data/lib/vedeu/terminal.rb +3 -3
  23. data/lib/vedeu/version.rb +1 -1
  24. data/test/lib/vedeu/bindings_test.rb +2 -2
  25. data/test/lib/vedeu/borders/border_test.rb +2 -6
  26. data/test/lib/vedeu/borders/render_border_test.rb +2 -2
  27. data/test/lib/vedeu/cli/generator/application_test.rb +2 -2
  28. data/test/lib/vedeu/cli/generator/view_test.rb +2 -2
  29. data/test/lib/vedeu/cli/main_test.rb +4 -4
  30. data/test/lib/vedeu/configuration/configuration_test.rb +6 -6
  31. data/test/lib/vedeu/cursor/cursor_test.rb +6 -6
  32. data/test/lib/vedeu/cursor/cursors_test.rb +4 -4
  33. data/test/lib/vedeu/cursor/move_test.rb +2 -2
  34. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +2 -2
  35. data/test/lib/vedeu/cursor/reposition_test.rb +2 -2
  36. data/test/lib/vedeu/distributed/client_test.rb +2 -2
  37. data/test/lib/vedeu/distributed/server_test.rb +3 -5
  38. data/test/lib/vedeu/dsl/border_test.rb +2 -2
  39. data/test/lib/vedeu/dsl/composition_test.rb +3 -3
  40. data/test/lib/vedeu/dsl/interface_test.rb +8 -8
  41. data/test/lib/vedeu/dsl/line_test.rb +2 -2
  42. data/test/lib/vedeu/dsl/use_test.rb +0 -24
  43. data/test/lib/vedeu/events/event_aliases_test.rb +9 -0
  44. data/test/lib/vedeu/events/event_test.rb +5 -5
  45. data/test/lib/vedeu/geometry/coordinate_test.rb +2 -2
  46. data/test/lib/vedeu/input/input_test.rb +2 -2
  47. data/test/lib/vedeu/input/keymap_test.rb +2 -2
  48. data/test/lib/vedeu/log/timer_test.rb +2 -2
  49. data/test/lib/vedeu/models/focus_test.rb +16 -24
  50. data/test/lib/vedeu/models/interfaces_test.rb +2 -2
  51. data/test/lib/vedeu/null/view_test.rb +44 -0
  52. data/test/lib/vedeu/output/clear/named_interface_test.rb +2 -2
  53. data/test/lib/vedeu/output/output_test.rb +2 -2
  54. data/test/lib/vedeu/output/renderers_test.rb +2 -2
  55. data/test/lib/vedeu/output/viewport_test.rb +2 -2
  56. data/test/lib/vedeu/plugins/plugin_test.rb +9 -0
  57. data/test/lib/vedeu/runtime/application_test.rb +2 -2
  58. data/test/lib/vedeu/runtime/launcher_test.rb +2 -2
  59. data/test/lib/vedeu/runtime/router_test.rb +8 -8
  60. data/test/lib/vedeu/templating/template_test.rb +2 -2
  61. data/test/lib/vedeu/templating/view_template_test.rb +4 -3
  62. data/test/lib/vedeu/terminal_mode_test.rb +2 -2
  63. data/test/lib/vedeu/terminal_test.rb +6 -10
  64. data/vedeu.gemspec +1 -1
  65. metadata +4 -4
@@ -22,10 +22,10 @@ module Vedeu
22
22
  y: y)
23
23
  }
24
24
 
25
- before {
25
+ before do
26
26
  Vedeu.borders.stubs(:by_name).returns(border)
27
27
  Vedeu.geometries.stubs(:by_name).returns(geometry)
28
- }
28
+ end
29
29
 
30
30
  describe '#initialize' do
31
31
  it { instance.must_be_instance_of(described) }
@@ -16,10 +16,10 @@ module Vedeu
16
16
  end
17
17
 
18
18
  describe '.capture' do
19
- before {
19
+ before do
20
20
  reader.stubs(:raw_mode?).returns(raw_mode)
21
21
  Vedeu.stubs(:trigger).returns([false])
22
- }
22
+ end
23
23
 
24
24
  subject { described.capture(reader) }
25
25
 
@@ -29,10 +29,10 @@ module Vedeu
29
29
  subject { instance.add(key) }
30
30
 
31
31
  context 'when the key is already defined' do
32
- before {
32
+ before do
33
33
  Vedeu.keymaps.reset
34
34
  instance.add(key)
35
- }
35
+ end
36
36
 
37
37
  it { subject.must_equal(false) }
38
38
  end
@@ -10,10 +10,10 @@ module Vedeu
10
10
  let(:_time) { mock('Time') }
11
11
  let(:started) { 1434492219.5238185 }
12
12
 
13
- before {
13
+ before do
14
14
  Time.stubs(:now).returns(_time)
15
15
  _time.stubs(:to_f).returns(started)
16
- }
16
+ end
17
17
 
18
18
  describe '#initialize' do
19
19
  it { instance.must_be_instance_of(described) }
@@ -6,28 +6,24 @@ module Vedeu
6
6
 
7
7
  let(:described) { Vedeu::Focus }
8
8
 
9
- before {
9
+ before do
10
10
  Vedeu::Focus.reset
11
11
  Vedeu.interfaces.reset
12
12
 
13
13
  Vedeu.stubs(:trigger)
14
- }
15
- after {
14
+ end
15
+ after do
16
16
  Vedeu::Focus.reset
17
17
  Vedeu.interfaces.reset
18
- }
18
+ end
19
19
 
20
20
  describe '#add' do
21
21
  context 'adds an interface to storage' do
22
- it {
23
- Vedeu::Focus.add('thallium').must_equal(['thallium'])
24
- }
22
+ it { Vedeu::Focus.add('thallium').must_equal(['thallium']) }
25
23
  end
26
24
 
27
25
  context 'does not add it again if already exists' do
28
- before {
29
- Vedeu.interface('thallium') {}
30
- }
26
+ before { Vedeu.interface('thallium') {} }
31
27
 
32
28
  it {
33
29
  Vedeu::Focus.add('thallium')
@@ -44,9 +40,7 @@ module Vedeu
44
40
  end
45
41
 
46
42
  context 'adds the interface to storage focussed' do
47
- before {
48
- Vedeu.interface('thallium') {}
49
- }
43
+ before { Vedeu.interface('thallium') {} }
50
44
 
51
45
  it {
52
46
  Vedeu::Focus.add('thallium')
@@ -56,9 +50,7 @@ module Vedeu
56
50
  end
57
51
 
58
52
  context 'adds the interface to storage unfocussed' do
59
- before {
60
- Vedeu.interface('thallium') {}
61
- }
53
+ before { Vedeu.interface('thallium') {} }
62
54
 
63
55
  it {
64
56
  Vedeu::Focus.add('thallium')
@@ -158,12 +150,12 @@ module Vedeu
158
150
  end
159
151
 
160
152
  describe '#next_visible_item' do
161
- before {
153
+ before do
162
154
  Vedeu.stubs(:trigger)
163
155
  Vedeu.interface('gold') { visible true }
164
156
  Vedeu.interface('silver') { visible true }
165
157
  Vedeu.interface('platinum') { visible false }
166
- }
158
+ end
167
159
 
168
160
  it 'the next visible interface is focussed when the method is called' do
169
161
  Vedeu::Focus.next_visible_item.must_equal('silver')
@@ -204,23 +196,23 @@ module Vedeu
204
196
  end
205
197
 
206
198
  describe '#prev_visible_item' do
207
- before {
199
+ before do
208
200
  Vedeu.stubs(:trigger)
209
201
  Vedeu.interface('gold') { visible true }
210
202
  Vedeu.interface('silver') { visible true }
211
203
  Vedeu.interface('platinum') { visible false }
212
- }
204
+ end
213
205
 
214
206
  it 'the previous visible interface is focussed when the method is called' do
215
207
  Vedeu::Focus.prev_visible_item.must_equal('silver')
216
208
  end
217
209
 
218
210
  context 'when there are no visible interfaces' do
219
- before {
211
+ before do
220
212
  Vedeu.interface('gold') { visible false }
221
213
  Vedeu.interface('silver') { visible false }
222
214
  Vedeu.interface('platinum') { visible false }
223
- }
215
+ end
224
216
 
225
217
  it 'puts the first interface defined in focus' do
226
218
  Vedeu::Focus.prev_visible_item.must_equal('gold')
@@ -235,10 +227,10 @@ module Vedeu
235
227
  end
236
228
 
237
229
  describe '#refresh' do
238
- before {
230
+ before do
239
231
  Vedeu::Focus.add('thallium')
240
232
  Vedeu.stubs(:trigger).returns([])
241
- }
233
+ end
242
234
 
243
235
  it 'triggers the event to refresh the interface current in focus' do
244
236
  Vedeu::Focus.refresh.must_equal([])
@@ -9,7 +9,7 @@ module Vedeu
9
9
  it { described.must_respond_to(:interfaces) }
10
10
 
11
11
  describe '#zindexed' do
12
- before {
12
+ before do
13
13
  Vedeu.interfaces.reset
14
14
 
15
15
  @hydrogen = Vedeu.interface('hydrogen') do
@@ -21,7 +21,7 @@ module Vedeu
21
21
  @lithium = Vedeu.interface('lithium') do
22
22
  zindex 1
23
23
  end
24
- }
24
+ end
25
25
  after { Vedeu.interfaces.reset }
26
26
 
27
27
  subject { Vedeu.interfaces.zindexed }
@@ -5,6 +5,50 @@ module Vedeu
5
5
  module Null
6
6
 
7
7
  describe View do
8
+
9
+ let(:described) { Vedeu::Null::View }
10
+ let(:instance) { described.new(attributes) }
11
+ let(:attributes) {
12
+ {
13
+ name: 'vedeu_null_view',
14
+ visible: true,
15
+ }
16
+ }
17
+
18
+ describe '#initialize' do
19
+ it { instance.must_be_instance_of(described) }
20
+ it { instance.instance_variable_get('@attributes').must_equal(attributes) }
21
+ it { instance.instance_variable_get('@name').must_equal('vedeu_null_view') }
22
+ it { instance.instance_variable_get('@visible').must_equal(false) }
23
+ end
24
+
25
+ describe 'accessors' do
26
+ it { instance.must_respond_to(:name) }
27
+ it { instance.must_respond_to(:attributes) }
28
+ it { instance.must_respond_to(:visible) }
29
+ it { instance.must_respond_to(:visible=) }
30
+ it { instance.must_respond_to(:visible?) }
31
+ end
32
+
33
+ describe '#null' do
34
+ it { instance.null.must_equal(nil) }
35
+
36
+ it { instance.must_respond_to(:parent) }
37
+ it { instance.must_respond_to(:zindex) }
38
+ end
39
+
40
+ describe '#null?' do
41
+ it { instance.null?.must_equal(true) }
42
+ end
43
+
44
+ describe '#store' do
45
+ it { instance.store.must_equal(instance) }
46
+ end
47
+
48
+ describe '#visible?' do
49
+ it { instance.visible?.must_equal(false) }
50
+ end
51
+
8
52
  end # View
9
53
 
10
54
  end # Null
@@ -28,10 +28,10 @@ module Vedeu
28
28
  Vedeu::Geometry.new(name: _name, x: 1, y: 1, xn: 2, yn: 2)
29
29
  }
30
30
 
31
- before {
31
+ before do
32
32
  Vedeu.interfaces.stubs(:by_name).returns(interface)
33
33
  Vedeu.geometries.stubs(:by_name).returns(geometry)
34
- }
34
+ end
35
35
 
36
36
  subject { instance.render }
37
37
 
@@ -25,10 +25,10 @@ module Vedeu
25
25
  let(:drb) { true }
26
26
  let(:virtual_buffer) { [] }
27
27
 
28
- before {
28
+ before do
29
29
  # Vedeu::Renderers::HTML.stubs(:to_file)
30
30
  Vedeu::VirtualBuffer.stubs(:retrieve).returns(virtual_buffer)
31
- }
31
+ end
32
32
 
33
33
  it {
34
34
  Vedeu.expects(:trigger).with(:_drb_store_output_, output)
@@ -57,10 +57,10 @@ module Vedeu
57
57
  describe '.render' do
58
58
  let(:output) {}
59
59
 
60
- before {
60
+ before do
61
61
  Vedeu::Renderers.reset
62
62
  Vedeu::Renderers.renderer(DummyRenderer)
63
- }
63
+ end
64
64
 
65
65
  subject { described.render(output) }
66
66
 
@@ -22,10 +22,10 @@ module Vedeu
22
22
  let(:interface) { Vedeu::Interface.new(style: nil, visible: visible) }
23
23
  let(:geometry) { Vedeu::Geometry.new(height: 3, width: 3) }
24
24
 
25
- before {
25
+ before do
26
26
  Vedeu.interfaces.stubs(:by_name).returns(interface)
27
27
  Vedeu.geometries.stubs(:by_name).returns(geometry)
28
- }
28
+ end
29
29
  after { Vedeu.interfaces.reset }
30
30
 
31
31
  describe '#initialize' do
@@ -23,6 +23,15 @@ module Vedeu
23
23
  describe '#load!' do
24
24
  subject { instance.load! }
25
25
 
26
+ context 'when the plugin gem cannot be loaded' do
27
+ before do
28
+ Kernel.stubs(:require).raises(LoadError)
29
+ end
30
+
31
+ it { proc { subject }.must_raise(Vedeu::VedeuError) }
32
+ it { instance.enabled.must_equal(false) }
33
+ end
34
+
26
35
  # @todo Add more tests.
27
36
  # it { skip }
28
37
  end
@@ -8,12 +8,12 @@ module Vedeu
8
8
  let(:instance) { described.new(configuration) }
9
9
  let(:configuration) { Vedeu.configuration }
10
10
 
11
- before {
11
+ before do
12
12
  configuration.stubs(:drb?).returns(false)
13
13
  Terminal.stubs(:open).returns([''])
14
14
 
15
15
  Vedeu.stubs(:trigger)
16
- }
16
+ end
17
17
 
18
18
  describe '#initialize' do
19
19
  it { instance.must_be_instance_of(described) }
@@ -32,12 +32,12 @@ module Vedeu
32
32
  end
33
33
 
34
34
  describe '#execute!' do
35
- before {
35
+ before do
36
36
  Configuration.stubs(:configure)# .returns(test_configuration)
37
37
  Application.stubs(:start)
38
38
  Kernel.stubs(:exit)
39
39
  Kernel.stubs(:puts)
40
- }
40
+ end
41
41
 
42
42
  subject { instance.execute! }
43
43
 
@@ -33,10 +33,10 @@ module Vedeu
33
33
  let(:controller) { :some_controller }
34
34
 
35
35
  context 'when the controller is registered' do
36
- before {
36
+ before do
37
37
  described.add_controller(controller, '')
38
38
  described.add_action(controller, :show_basket)
39
- }
39
+ end
40
40
  after { described.reset! }
41
41
 
42
42
  it {
@@ -129,10 +129,10 @@ module Vedeu
129
129
 
130
130
  context 'when the controller is registered' do
131
131
  context 'when the controller klass is defined' do
132
- before {
132
+ before do
133
133
  described.add_controller(controller, 'Vedeu::SomeController')
134
134
  described.add_action(controller, action)
135
- }
135
+ end
136
136
  after { described.reset! }
137
137
 
138
138
  it {
@@ -151,18 +151,18 @@ module Vedeu
151
151
  context 'when the action is not defined for this controller' do
152
152
  let(:action) { :undefined_action }
153
153
 
154
- before {
154
+ before do
155
155
  described.add_controller(controller, 'Vedeu::SomeController')
156
- }
156
+ end
157
157
 
158
158
  it { proc { subject }.must_raise(Vedeu::ActionNotFound) }
159
159
  end
160
160
 
161
161
  context 'when the controller klass is not defined' do
162
- before {
162
+ before do
163
163
  described.add_controller(controller, '')
164
164
  described.add_action(controller, action)
165
- }
165
+ end
166
166
  after { described.reset! }
167
167
 
168
168
  it { proc { subject }.must_raise(Vedeu::MissingRequired) }
@@ -38,10 +38,10 @@ module Vedeu
38
38
  let(:path) { '/tmp/vedeu_exists' }
39
39
  let(:expected) { "This is a test.\n" }
40
40
 
41
- before {
41
+ before do
42
42
  File.stubs(:exist?).returns(true)
43
43
  File.stubs(:read).returns(expected)
44
- }
44
+ end
45
45
 
46
46
  it { subject.must_equal(expected) }
47
47
  end
@@ -7,16 +7,17 @@ module Vedeu
7
7
  describe ViewTemplate do
8
8
 
9
9
  let(:described) { Vedeu::Templating::ViewTemplate }
10
- let(:instance) { described.new(object, path) }
10
+ let(:instance) { described.new(object, path, options) }
11
11
  let(:object) {}
12
12
  let(:path) { '/tmp/some_template.erb' }
13
+ let(:options) { {} }
13
14
  let(:content) { '' }
14
15
 
15
16
  describe '.parse' do
16
- before {
17
+ before do
17
18
  File.stubs(:exist?).returns(true)
18
19
  File.stubs(:read).returns(content)
19
- }
20
+ end
20
21
 
21
22
  subject { described.parse(object, path) }
22
23
 
@@ -55,10 +55,10 @@ module Vedeu
55
55
  describe '.mode' do
56
56
  subject { described.mode }
57
57
 
58
- before {
58
+ before do
59
59
  described.raw_mode!
60
60
  Configuration.stubs(:terminal_mode).returns(:raw)
61
- }
61
+ end
62
62
 
63
63
  it { subject.must_be_instance_of(Symbol) }
64
64
 
@@ -7,10 +7,10 @@ module Vedeu
7
7
  let(:described) { Vedeu::Terminal }
8
8
  let(:console) { IO.console }
9
9
 
10
- before {
10
+ before do
11
11
  console.stubs(:winsize).returns([25, 80])
12
12
  console.stubs(:print)
13
- }
13
+ end
14
14
 
15
15
  describe '.open' do
16
16
  context 'when a block was not given' do
@@ -47,10 +47,10 @@ module Vedeu
47
47
  let(:mode) { :cooked }
48
48
  let(:input) { "Some input\r\n" }
49
49
 
50
- before {
50
+ before do
51
51
  Terminal.stubs(:mode).returns(mode)
52
52
  console.stubs(:gets).returns(input)
53
- }
53
+ end
54
54
 
55
55
  it { subject.must_equal('Some input') }
56
56
  end
@@ -59,12 +59,12 @@ module Vedeu
59
59
  let(:mode) { :raw }
60
60
  let(:input) { "\e" }
61
61
 
62
- before {
62
+ before do
63
63
  Terminal.stubs(:mode).returns(mode)
64
64
  console.stubs(:getch).returns(input)
65
65
  input.stubs(:ord).returns(27)
66
66
  console.stubs(:read_nonblock)
67
- }
67
+ end
68
68
 
69
69
  it { subject.must_be_instance_of(String) }
70
70
  end
@@ -164,9 +164,7 @@ module Vedeu
164
164
  subject { Terminal.origin }
165
165
 
166
166
  it { subject.must_be_instance_of(Fixnum) }
167
-
168
167
  it { subject.must_equal(1) }
169
-
170
168
  it { described.must_respond_to(:x) }
171
169
  it { described.must_respond_to(:y) }
172
170
  it { described.must_respond_to(:tx) }
@@ -177,7 +175,6 @@ module Vedeu
177
175
  subject { Terminal.width }
178
176
 
179
177
  it { subject.must_be_instance_of(Fixnum) }
180
-
181
178
  it { described.must_respond_to(:xn) }
182
179
  it { described.must_respond_to(:txn) }
183
180
 
@@ -198,7 +195,6 @@ module Vedeu
198
195
  subject { Terminal.height }
199
196
 
200
197
  it { subject.must_be_instance_of(Fixnum) }
201
-
202
198
  it { described.must_respond_to(:yn) }
203
199
  it { described.must_respond_to(:tyn) }
204
200