vedeu 0.4.61 → 0.4.62

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vedeu/all.rb +2 -0
  3. data/lib/vedeu/application/controller.rb +41 -9
  4. data/lib/vedeu/bindings.rb +4 -1
  5. data/lib/vedeu/bindings/application.rb +36 -0
  6. data/lib/vedeu/bootstrap.rb +6 -1
  7. data/lib/vedeu/cli/generator/templates/application/app/controllers/name.erb +10 -4
  8. data/lib/vedeu/colours/colour.rb +6 -9
  9. data/lib/vedeu/repositories/model.rb +1 -1
  10. data/lib/vedeu/router.rb +117 -0
  11. data/lib/vedeu/version.rb +1 -1
  12. data/test/lib/vedeu/application/application_controller_test.rb +1 -1
  13. data/test/lib/vedeu/application/application_helper_test.rb +1 -1
  14. data/test/lib/vedeu/application/controller_test.rb +35 -11
  15. data/test/lib/vedeu/application/helper_test.rb +1 -1
  16. data/test/lib/vedeu/bindings/application_test.rb +38 -0
  17. data/test/lib/vedeu/bindings_test.rb +45 -0
  18. data/test/lib/vedeu/borders/render_border_test.rb +1 -1
  19. data/test/lib/vedeu/buffers/buffer_test.rb +1 -1
  20. data/test/lib/vedeu/buffers/display_buffer_test.rb +2 -2
  21. data/test/lib/vedeu/cli/generator/application_test.rb +1 -1
  22. data/test/lib/vedeu/cli/generator/helpers_test.rb +1 -1
  23. data/test/lib/vedeu/colours/colour_test.rb +9 -1
  24. data/test/lib/vedeu/configuration/api_test.rb +3 -3
  25. data/test/lib/vedeu/cursor/move_test.rb +5 -5
  26. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +4 -0
  27. data/test/lib/vedeu/distributed/client_test.rb +4 -4
  28. data/test/lib/vedeu/distributed/server_test.rb +9 -9
  29. data/test/lib/vedeu/dsl/use_test.rb +4 -4
  30. data/test/lib/vedeu/launcher_test.rb +2 -2
  31. data/test/lib/vedeu/main_loop_test.rb +2 -2
  32. data/test/lib/vedeu/output/refresh_group_test.rb +1 -1
  33. data/test/lib/vedeu/output/refresh_test.rb +1 -1
  34. data/test/lib/vedeu/output/renderers/html_test.rb +1 -1
  35. data/test/lib/vedeu/output/renderers/renderer_options_test.rb +1 -1
  36. data/test/lib/vedeu/output/renderers_test.rb +2 -2
  37. data/test/lib/vedeu/output/text_test.rb +2 -2
  38. data/test/lib/vedeu/plugins/plugin_test.rb +1 -1
  39. data/test/lib/vedeu/plugins_test.rb +2 -2
  40. data/test/lib/vedeu/repositories/collection_test.rb +1 -1
  41. data/test/lib/vedeu/repositories/model_test.rb +18 -3
  42. data/test/lib/vedeu/{repositories/all_test.rb → repositories_test.rb} +0 -0
  43. data/test/lib/vedeu/router_test.rb +192 -0
  44. data/test/lib/vedeu/traps_test.rb +1 -1
  45. data/test/lib/vedeu_test.rb +1 -1
  46. data/test/support/coverage.rb +42 -0
  47. data/vedeu.gemspec +2 -2
  48. metadata +14 -4
@@ -4,7 +4,7 @@ module Vedeu
4
4
 
5
5
  describe RendererOptions do
6
6
 
7
- # @todo
7
+ # @todo Add more tests.
8
8
  # it { skip }
9
9
 
10
10
  end # RendererOptions
@@ -32,14 +32,14 @@ module Vedeu
32
32
 
33
33
  subject { Vedeu.renderers.render(output) }
34
34
 
35
- # @todo
35
+ # @todo Add more tests.
36
36
  # context 'when a single renderer is defined' do
37
37
  # let(:renderers) { DummyRenderer }
38
38
 
39
39
  # it { subject.must_equal([:dummy]) }
40
40
  # end
41
41
 
42
- # @todo
42
+ # @todo Add more tests.
43
43
  # context 'when multiple renderers are defined' do
44
44
  # let(:renderers) { [DummyRenderer, FooRenderer] }
45
45
 
@@ -133,7 +133,7 @@ module Vedeu
133
133
  context 'when the colour option is given' do
134
134
  let(:colour) { { background: '#33ff33', foreground: '#ffaa00' } }
135
135
 
136
- # @todo
136
+ # @todo Add more tests.
137
137
  # it { skip }
138
138
  end
139
139
 
@@ -141,7 +141,7 @@ module Vedeu
141
141
  let(:background) { '#111111' }
142
142
  let(:foreground) { '#aadd00' }
143
143
 
144
- # @todo
144
+ # @todo Add more tests.
145
145
  # it { skip }
146
146
  end
147
147
 
@@ -23,7 +23,7 @@ module Vedeu
23
23
  describe '#load!' do
24
24
  subject { instance.load! }
25
25
 
26
- # @todo
26
+ # @todo Add more tests.
27
27
  # it { skip }
28
28
  end
29
29
 
@@ -23,7 +23,7 @@ module Vedeu
23
23
 
24
24
  subject { instance.register(_name, plugin) }
25
25
 
26
- # @todo
26
+ # @todo Add more tests.
27
27
  # it { skip }
28
28
  end
29
29
 
@@ -43,7 +43,7 @@ module Vedeu
43
43
  end
44
44
 
45
45
  context 'when plugins are registered' do
46
- # @todo
46
+ # @todo Add more tests.
47
47
  # it { skip }
48
48
  end
49
49
  end
@@ -29,7 +29,7 @@ module Vedeu
29
29
  describe '.coerce' do
30
30
  subject { described.coerce(collection, parent, model_name) }
31
31
 
32
- # @todo
32
+ # @todo Add more tests.
33
33
  # it { skip }
34
34
  end
35
35
 
@@ -41,10 +41,25 @@ module Vedeu
41
41
 
42
42
  subject { described.build(attributes) { } }
43
43
 
44
- # @todo
44
+ # @todo Add more tests.
45
45
  # it { skip }
46
46
  end
47
47
 
48
+ describe '.by_name' do
49
+ let(:_name) {}
50
+
51
+ subject { described.by_name(_name) }
52
+
53
+ context 'when the model has no repository set' do
54
+ it { subject.must_be_instance_of(NilClass) }
55
+ end
56
+
57
+ context 'when the model has a repository set' do
58
+ # @todo Add more tests.
59
+ # it { skip }
60
+ end
61
+ end
62
+
48
63
  describe '.child' do
49
64
  let(:klass) {}
50
65
 
@@ -53,7 +68,7 @@ module Vedeu
53
68
  it { described.must_respond_to(:member) }
54
69
  it { described.must_respond_to(:collection) }
55
70
 
56
- # @todo
71
+ # @todo Add more tests.
57
72
  # it { skip }
58
73
  end
59
74
 
@@ -62,7 +77,7 @@ module Vedeu
62
77
 
63
78
  subject { described.repository(klass) }
64
79
 
65
- # @todo
80
+ # @todo Add more tests.
66
81
  # it { skip }
67
82
  end
68
83
 
@@ -0,0 +1,192 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ class SomeController
6
+
7
+ def some_action(customer_id:, product_id:)
8
+ {
9
+ customer: { name: 'Gavin Laking', customer_id: customer_id },
10
+ basket: { product_ids: [product_id] }
11
+ }
12
+ end
13
+
14
+ end # SomeController
15
+
16
+ describe Router do
17
+
18
+ let(:described) { Vedeu::Router }
19
+
20
+ before { described.reset! }
21
+
22
+ describe '.add_controller' do
23
+ let(:controller_name) {}
24
+ let(:klass) { "SomeController" }
25
+
26
+ subject { described.add_controller(controller_name, klass) }
27
+
28
+ context 'when a name is not given' do
29
+ it { proc { subject }.must_raise(Vedeu::MissingRequired) }
30
+ end
31
+
32
+ context 'when a name is given' do
33
+ let(:controller_name) { :some_controller }
34
+
35
+ context 'when the controller is registered' do
36
+ before do
37
+ described.add_controller(controller_name, '')
38
+ described.add_action(controller_name, :show_basket)
39
+ end
40
+ after { described.reset! }
41
+
42
+ it {
43
+ subject.must_equal({
44
+ some_controller: {
45
+ klass: 'SomeController',
46
+ actions: [:show_basket]
47
+ }
48
+ })
49
+ }
50
+ end
51
+
52
+ context 'when the controller is not registered' do
53
+ it {
54
+ subject.must_equal({
55
+ some_controller: {
56
+ klass: 'SomeController',
57
+ actions: []
58
+ }
59
+ })
60
+ }
61
+ end
62
+ end
63
+ end
64
+
65
+ describe '.add_action' do
66
+ let(:controller_name) {}
67
+ let(:action_name) {}
68
+
69
+ subject { described.add_action(controller_name, action_name) }
70
+
71
+ context 'when the controller is not given' do
72
+ let(:action_name) { :some_action }
73
+
74
+ it { proc { subject }.must_raise(Vedeu::MissingRequired) }
75
+ end
76
+
77
+ context 'when the name is not given' do
78
+ let(:controller_name) { :some_controller }
79
+
80
+ it { proc { subject }.must_raise(Vedeu::MissingRequired) }
81
+ end
82
+
83
+ context 'when the controller and name is given' do
84
+ let(:controller_name) { :some_controller }
85
+ let(:action_name) { :some_action }
86
+
87
+ context 'when the controller is registered' do
88
+ before { described.add_controller(controller_name, 'SomeController') }
89
+ after { described.reset! }
90
+
91
+ it {
92
+ subject.must_equal({
93
+ some_controller: {
94
+ klass: 'SomeController',
95
+ actions: [:some_action]
96
+ }
97
+ })
98
+ }
99
+ end
100
+
101
+ context 'when the controller is not registered' do
102
+ before { described.reset! }
103
+
104
+ it {
105
+ subject.must_equal({
106
+ some_controller: {
107
+ klass: '',
108
+ actions: [:some_action]
109
+ }
110
+ })
111
+ }
112
+ end
113
+ end
114
+ end
115
+
116
+ describe '.goto' do
117
+ let(:controller_name) { :some_controller }
118
+ let(:action_name) { :some_action }
119
+ let(:args) {
120
+ {
121
+ customer_id: 7,
122
+ product_id: 88,
123
+ }
124
+ }
125
+
126
+ subject { described.goto(controller_name, action_name, **args) }
127
+
128
+ context 'when the controller is registered' do
129
+ context 'when the controller klass is defined' do
130
+ before do
131
+ described.add_controller(controller_name, 'Vedeu::SomeController')
132
+ described.add_action(controller_name, action_name)
133
+ end
134
+ after { described.reset! }
135
+
136
+ it {
137
+ subject.must_equal({
138
+ customer: {
139
+ name: 'Gavin Laking',
140
+ customer_id: 7
141
+ },
142
+ basket: {
143
+ product_ids: [88]
144
+ }
145
+ })
146
+ }
147
+ end
148
+
149
+ context 'when the controller klass is not defined' do
150
+ before do
151
+ described.add_controller(controller_name, '')
152
+ described.add_action(controller_name, action_name)
153
+ end
154
+ after { described.reset! }
155
+
156
+ it { proc { subject }.must_raise(Vedeu::MissingRequired) }
157
+ end
158
+ end
159
+
160
+ context 'when the controller is not registered' do
161
+ it { proc { subject }.must_raise(Vedeu::ModelNotFound) }
162
+ end
163
+ end
164
+
165
+ describe '.registered' do
166
+ let(:controller_name) { :some_controller }
167
+
168
+ subject { described.registered?(controller_name) }
169
+
170
+ context 'when the controller is registered' do
171
+ before { described.add_controller(controller_name, "SomeController") }
172
+ after { described.reset! }
173
+
174
+ it { subject.must_equal(true) }
175
+ end
176
+
177
+ context 'when the controller is not registered' do
178
+ it { subject.must_equal(false) }
179
+ end
180
+ end
181
+
182
+ describe '.reset!' do
183
+ subject { described.reset! }
184
+
185
+ it { subject.must_equal({}) }
186
+
187
+ it { described.must_respond_to(:reset) }
188
+ end
189
+
190
+ end # Router
191
+
192
+ end # Vedeu
@@ -4,7 +4,7 @@ module Vedeu
4
4
 
5
5
  describe Traps do
6
6
 
7
- # @todo
7
+ # @todo Add more tests.
8
8
  # it { skip }
9
9
 
10
10
  end # Traps
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  describe Vedeu do
4
4
 
5
5
  # ...
6
- # @todo
6
+ # @todo Add more tests.
7
7
  # it { skip }
8
8
 
9
9
  end # Vedeu
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Find all methods which don't have corresponding test method, or all test
4
+ # methods without corresponding method. Produces quite a few false positives,
5
+ # but useful for a quick check.
6
+
7
+ source_files = Dir.glob("lib/vedeu/**/*.rb")
8
+ test_files = Dir.glob("test/lib/vedeu/**/*_test.rb")
9
+
10
+ test_files.each do |test_file|
11
+ source_file = test_file.gsub(/^test\/|_test/, '')
12
+ if File.exist?(source_file)
13
+ source_defs = File.readlines(source_file).select { |line| line[/def /] }.map(&:lstrip).map do |line|
14
+ line.chomp!
15
+ line.gsub!(/^def /, '')
16
+ line.gsub(/\(.*/, '')
17
+ end
18
+
19
+ defs = File.readlines(test_file).select { |line| line[/describe /] }.map(&:lstrip).map do |line|
20
+ line.chomp!
21
+ line.gsub!(/^describe /, '')
22
+ line.gsub!(/ do$/, '')
23
+ end
24
+ test_defs = defs.keep_if { |line| line =~ /\'/ }.map { |line| line.gsub!(/\'|#|\./, '') }
25
+
26
+ unless (test_defs - source_defs).empty?
27
+ puts "\e[33m#{test_file} \e[31m(test without source)\e[39m\n #{(test_defs - source_defs).inspect}"
28
+ end
29
+
30
+ unless (source_defs - test_defs).empty?
31
+ puts "\e[34m#{source_file} \e[31m(source without test)\e[39m\n #{(source_defs - test_defs).inspect}"
32
+ end
33
+
34
+ puts
35
+
36
+ else
37
+ puts "#{test_file} has no matching source file."
38
+
39
+ end
40
+ end
41
+
42
+
data/vedeu.gemspec CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ['Gavin Laking']
11
11
  spec.email = ['gavinlaking@gmail.com']
12
12
  spec.summary = 'A terminal case of wonderland.'
13
- spec.description = 'A GUI framework written in Ruby for building ' \
14
- 'terminal/console applications.'
13
+ spec.description = 'A GUI/TUI framework for building terminal/console ' \
14
+ 'applications.'
15
15
  spec.homepage = 'https://github.com/gavinlaking/vedeu'
16
16
  spec.license = 'MIT'
17
17
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vedeu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.61
4
+ version: 0.4.62
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Laking
@@ -206,7 +206,7 @@ dependencies:
206
206
  - - '='
207
207
  - !ruby/object:Gem::Version
208
208
  version: 0.19.1
209
- description: A GUI framework written in Ruby for building terminal/console applications.
209
+ description: A GUI/TUI framework for building terminal/console applications.
210
210
  email:
211
211
  - gavinlaking@gmail.com
212
212
  executables:
@@ -269,6 +269,7 @@ files:
269
269
  - lib/vedeu/application/helper.rb
270
270
  - lib/vedeu/application/view.rb
271
271
  - lib/vedeu/bindings.rb
272
+ - lib/vedeu/bindings/application.rb
272
273
  - lib/vedeu/bindings/drb.rb
273
274
  - lib/vedeu/bindings/menus.rb
274
275
  - lib/vedeu/bindings/movement.rb
@@ -434,6 +435,7 @@ files:
434
435
  - lib/vedeu/repositories/registerable.rb
435
436
  - lib/vedeu/repositories/repository.rb
436
437
  - lib/vedeu/repositories/store.rb
438
+ - lib/vedeu/router.rb
437
439
  - lib/vedeu/templating/all.rb
438
440
  - lib/vedeu/templating/decoder.rb
439
441
  - lib/vedeu/templating/directive.rb
@@ -454,11 +456,13 @@ files:
454
456
  - test/lib/vedeu/application/helper_test.rb
455
457
  - test/lib/vedeu/application/view_test.rb
456
458
  - test/lib/vedeu/application_test.rb
459
+ - test/lib/vedeu/bindings/application_test.rb
457
460
  - test/lib/vedeu/bindings/drb_test.rb
458
461
  - test/lib/vedeu/bindings/menus_test.rb
459
462
  - test/lib/vedeu/bindings/movement_test.rb
460
463
  - test/lib/vedeu/bindings/system_test.rb
461
464
  - test/lib/vedeu/bindings/visibility_test.rb
465
+ - test/lib/vedeu/bindings_test.rb
462
466
  - test/lib/vedeu/bootstrap_test.rb
463
467
  - test/lib/vedeu/borders/border_test.rb
464
468
  - test/lib/vedeu/borders/borders_test.rb
@@ -579,12 +583,13 @@ files:
579
583
  - test/lib/vedeu/output/wordwrap_test.rb
580
584
  - test/lib/vedeu/plugins/plugin_test.rb
581
585
  - test/lib/vedeu/plugins_test.rb
582
- - test/lib/vedeu/repositories/all_test.rb
583
586
  - test/lib/vedeu/repositories/collection_test.rb
584
587
  - test/lib/vedeu/repositories/model_test.rb
585
588
  - test/lib/vedeu/repositories/registerable_test.rb
586
589
  - test/lib/vedeu/repositories/repository_test.rb
587
590
  - test/lib/vedeu/repositories/store_test.rb
591
+ - test/lib/vedeu/repositories_test.rb
592
+ - test/lib/vedeu/router_test.rb
588
593
  - test/lib/vedeu/templating/decoder_test.rb
589
594
  - test/lib/vedeu/templating/directive_test.rb
590
595
  - test/lib/vedeu/templating/encoder_test.rb
@@ -597,6 +602,7 @@ files:
597
602
  - test/lib/vedeu/traps_test.rb
598
603
  - test/lib/vedeu_test.rb
599
604
  - test/support/all_seeds.sh
605
+ - test/support/coverage.rb
600
606
  - test/support/helpers/model_test_class.rb
601
607
  - test/support/stats.sh
602
608
  - test/support/templates/plain.erb
@@ -636,11 +642,13 @@ test_files:
636
642
  - test/lib/vedeu/application/helper_test.rb
637
643
  - test/lib/vedeu/application/view_test.rb
638
644
  - test/lib/vedeu/application_test.rb
645
+ - test/lib/vedeu/bindings/application_test.rb
639
646
  - test/lib/vedeu/bindings/drb_test.rb
640
647
  - test/lib/vedeu/bindings/menus_test.rb
641
648
  - test/lib/vedeu/bindings/movement_test.rb
642
649
  - test/lib/vedeu/bindings/system_test.rb
643
650
  - test/lib/vedeu/bindings/visibility_test.rb
651
+ - test/lib/vedeu/bindings_test.rb
644
652
  - test/lib/vedeu/bootstrap_test.rb
645
653
  - test/lib/vedeu/borders/border_test.rb
646
654
  - test/lib/vedeu/borders/borders_test.rb
@@ -761,12 +769,13 @@ test_files:
761
769
  - test/lib/vedeu/output/wordwrap_test.rb
762
770
  - test/lib/vedeu/plugins/plugin_test.rb
763
771
  - test/lib/vedeu/plugins_test.rb
764
- - test/lib/vedeu/repositories/all_test.rb
765
772
  - test/lib/vedeu/repositories/collection_test.rb
766
773
  - test/lib/vedeu/repositories/model_test.rb
767
774
  - test/lib/vedeu/repositories/registerable_test.rb
768
775
  - test/lib/vedeu/repositories/repository_test.rb
769
776
  - test/lib/vedeu/repositories/store_test.rb
777
+ - test/lib/vedeu/repositories_test.rb
778
+ - test/lib/vedeu/router_test.rb
770
779
  - test/lib/vedeu/templating/decoder_test.rb
771
780
  - test/lib/vedeu/templating/directive_test.rb
772
781
  - test/lib/vedeu/templating/encoder_test.rb
@@ -779,6 +788,7 @@ test_files:
779
788
  - test/lib/vedeu/traps_test.rb
780
789
  - test/lib/vedeu_test.rb
781
790
  - test/support/all_seeds.sh
791
+ - test/support/coverage.rb
782
792
  - test/support/helpers/model_test_class.rb
783
793
  - test/support/stats.sh
784
794
  - test/support/templates/plain.erb