vedeu 0.4.18 → 0.4.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Rakefile +1 -0
  4. data/bin/vedeu_drb_server +0 -1
  5. data/bin/vedeu_test +0 -1
  6. data/config/rubocop_enabled.yml +1 -1
  7. data/examples/borders_app.rb +0 -1
  8. data/examples/colours_app.rb +0 -1
  9. data/examples/cursor_app.rb +0 -1
  10. data/examples/drb_app.rb +0 -1
  11. data/examples/geometry_app.rb +0 -1
  12. data/examples/hello_world.rb +0 -1
  13. data/examples/lines_app.rb +0 -1
  14. data/examples/material_colours_app.rb +0 -1
  15. data/examples/typed_commands/typed_commands_app.rb +0 -1
  16. data/examples/view_templates_app/view_templates_app.rb +0 -1
  17. data/lib/vedeu/api.rb +2 -1
  18. data/lib/vedeu/application.rb +3 -2
  19. data/lib/vedeu/bindings.rb +3 -5
  20. data/lib/vedeu/buffers/buffer.rb +8 -11
  21. data/lib/vedeu/buffers/display_buffer.rb +0 -2
  22. data/lib/vedeu/configuration/api.rb +1 -4
  23. data/lib/vedeu/configuration/cli.rb +153 -74
  24. data/lib/vedeu/configuration/configuration.rb +1 -2
  25. data/lib/vedeu/cursor/cursor.rb +0 -4
  26. data/lib/vedeu/cursor/move.rb +3 -6
  27. data/lib/vedeu/cursor/refresh_cursor.rb +12 -2
  28. data/lib/vedeu/distributed/client.rb +3 -2
  29. data/lib/vedeu/distributed/server.rb +4 -3
  30. data/lib/vedeu/distributed/subprocess.rb +3 -4
  31. data/lib/vedeu/distributed/test_application.rb +0 -1
  32. data/lib/vedeu/distributed/uri.rb +0 -1
  33. data/lib/vedeu/dsl/components/border.rb +3 -4
  34. data/lib/vedeu/dsl/components/geometry.rb +1 -5
  35. data/lib/vedeu/dsl/components/keymap.rb +1 -3
  36. data/lib/vedeu/dsl/components/menu.rb +1 -2
  37. data/lib/vedeu/dsl/composition.rb +3 -4
  38. data/lib/vedeu/dsl/group.rb +1 -4
  39. data/lib/vedeu/dsl/interface.rb +3 -10
  40. data/lib/vedeu/dsl/line.rb +3 -4
  41. data/lib/vedeu/dsl/shared/text.rb +0 -3
  42. data/lib/vedeu/dsl/stream.rb +3 -4
  43. data/lib/vedeu/dsl/view.rb +0 -3
  44. data/lib/vedeu/events/event.rb +3 -3
  45. data/lib/vedeu/events/trigger.rb +3 -2
  46. data/lib/vedeu/geometry/area.rb +0 -1
  47. data/lib/vedeu/geometry/canvas.rb +0 -1
  48. data/lib/vedeu/geometry/coordinate.rb +6 -7
  49. data/lib/vedeu/geometry/dimension.rb +3 -2
  50. data/lib/vedeu/geometry/geometry.rb +0 -6
  51. data/lib/vedeu/geometry/grid.rb +3 -2
  52. data/lib/vedeu/geometry/index_position.rb +0 -1
  53. data/lib/vedeu/geometry/position.rb +0 -1
  54. data/lib/vedeu/geometry/position_index.rb +0 -1
  55. data/lib/vedeu/geometry/position_validator.rb +6 -68
  56. data/lib/vedeu/input/all.rb +0 -2
  57. data/lib/vedeu/input/input.rb +3 -2
  58. data/lib/vedeu/input/key.rb +0 -1
  59. data/lib/vedeu/input/keymap.rb +4 -7
  60. data/lib/vedeu/input/mapper.rb +3 -2
  61. data/lib/vedeu/launcher.rb +3 -2
  62. data/lib/vedeu/main_loop.rb +1 -1
  63. data/lib/vedeu/models/cell.rb +0 -1
  64. data/lib/vedeu/models/char.rb +0 -1
  65. data/lib/vedeu/models/composition.rb +1 -7
  66. data/lib/vedeu/models/group.rb +0 -3
  67. data/lib/vedeu/models/interface.rb +0 -3
  68. data/lib/vedeu/models/line.rb +0 -4
  69. data/lib/vedeu/models/menu.rb +5 -8
  70. data/lib/vedeu/models/stream.rb +0 -4
  71. data/lib/vedeu/null/all.rb +11 -0
  72. data/lib/vedeu/null/border.rb +3 -1
  73. data/lib/vedeu/null/buffer.rb +0 -1
  74. data/lib/vedeu/null/generic.rb +4 -1
  75. data/lib/vedeu/null/geometry.rb +0 -1
  76. data/lib/vedeu/null/interface.rb +36 -7
  77. data/lib/vedeu/output/background.rb +0 -1
  78. data/lib/vedeu/output/border.rb +1 -6
  79. data/lib/vedeu/output/clear.rb +3 -2
  80. data/lib/vedeu/output/colour.rb +6 -18
  81. data/lib/vedeu/output/compressor.rb +5 -2
  82. data/lib/vedeu/output/esc.rb +4 -1
  83. data/lib/vedeu/output/foreground.rb +0 -5
  84. data/lib/vedeu/output/html_char.rb +3 -2
  85. data/lib/vedeu/output/output.rb +1 -5
  86. data/lib/vedeu/output/refresh.rb +1 -1
  87. data/lib/vedeu/output/renderers/all.rb +0 -1
  88. data/lib/vedeu/output/renderers/escape_sequence.rb +3 -2
  89. data/lib/vedeu/output/renderers/file.rb +85 -80
  90. data/lib/vedeu/output/renderers/html.rb +77 -72
  91. data/lib/vedeu/output/renderers/json.rb +45 -42
  92. data/lib/vedeu/output/renderers/null.rb +11 -8
  93. data/lib/vedeu/output/renderers/terminal.rb +41 -36
  94. data/lib/vedeu/output/renderers/text.rb +41 -36
  95. data/lib/vedeu/output/style.rb +0 -3
  96. data/lib/vedeu/output/text.rb +3 -2
  97. data/lib/vedeu/output/viewport.rb +3 -2
  98. data/lib/vedeu/output/virtual_terminal.rb +0 -1
  99. data/lib/vedeu/output/wordwrap.rb +3 -2
  100. data/lib/vedeu/repositories/all.rb +7 -6
  101. data/lib/vedeu/repositories/collection.rb +0 -1
  102. data/lib/vedeu/repositories/collections/chars.rb +0 -1
  103. data/lib/vedeu/repositories/collections/events.rb +0 -1
  104. data/lib/vedeu/repositories/collections/interfaces.rb +0 -1
  105. data/lib/vedeu/repositories/collections/keys.rb +0 -1
  106. data/lib/vedeu/repositories/collections/lines.rb +0 -1
  107. data/lib/vedeu/repositories/collections/streams.rb +0 -1
  108. data/lib/vedeu/repositories/model.rb +0 -1
  109. data/lib/vedeu/repositories/registerable.rb +29 -0
  110. data/lib/vedeu/repositories/repositories/background_colours.rb +0 -1
  111. data/lib/vedeu/repositories/repositories/borders.rb +2 -13
  112. data/lib/vedeu/repositories/repositories/buffers.rb +2 -13
  113. data/lib/vedeu/repositories/repositories/colours.rb +0 -1
  114. data/lib/vedeu/repositories/repositories/cursors.rb +1 -2
  115. data/lib/vedeu/repositories/repositories/events_repository.rb +0 -1
  116. data/lib/vedeu/repositories/repositories/foreground_colours.rb +0 -1
  117. data/lib/vedeu/repositories/repositories/geometries.rb +2 -13
  118. data/lib/vedeu/repositories/repositories/groups.rb +1 -2
  119. data/lib/vedeu/repositories/repositories/interfaces_repository.rb +2 -14
  120. data/lib/vedeu/repositories/repositories/keymaps.rb +1 -2
  121. data/lib/vedeu/repositories/repositories/menus.rb +1 -2
  122. data/lib/vedeu/repositories/repository.rb +14 -5
  123. data/lib/vedeu/storage/all.rb +0 -1
  124. data/lib/vedeu/storage/associative_store.rb +0 -1
  125. data/lib/vedeu/storage/conveyor_store.rb +0 -1
  126. data/lib/vedeu/storage/fifo_store.rb +0 -1
  127. data/lib/vedeu/support/log.rb +0 -3
  128. data/lib/vedeu/support/options.rb +3 -2
  129. data/lib/vedeu/support/template.rb +3 -4
  130. data/lib/vedeu/support/terminal.rb +0 -2
  131. data/lib/vedeu/support/trace.rb +6 -7
  132. data/lib/vedeu/support/visibility.rb +1 -2
  133. data/lib/vedeu.rb +3 -5
  134. data/test/lib/vedeu/buffers/buffer_test.rb +48 -13
  135. data/test/lib/vedeu/configuration/cli_test.rb +5 -4
  136. data/test/lib/vedeu/cursor/refresh_cursor_test.rb +37 -15
  137. data/test/lib/vedeu/distributed/subprocess_test.rb +1 -0
  138. data/test/lib/vedeu/dsl/shared/use_test.rb +1 -6
  139. data/test/lib/vedeu/main_loop_test.rb +11 -0
  140. data/test/lib/vedeu/null/interface_test.rb +27 -0
  141. data/test/lib/vedeu/output/output_test.rb +17 -10
  142. data/test/lib/vedeu/output/presentation_test.rb +35 -7
  143. data/test/lib/vedeu/output/renderers/escape_sequence_test.rb +50 -0
  144. data/test/lib/vedeu/output/renderers/file_test.rb +34 -30
  145. data/test/lib/vedeu/output/renderers/html_test.rb +61 -57
  146. data/test/lib/vedeu/output/renderers/json_test.rb +40 -36
  147. data/test/lib/vedeu/output/renderers/null_test.rb +12 -8
  148. data/test/lib/vedeu/output/renderers/terminal_test.rb +17 -13
  149. data/test/lib/vedeu/output/renderers/text_test.rb +17 -13
  150. data/test/lib/vedeu/repositories/model_test.rb +1 -1
  151. data/test/lib/vedeu/repositories/registerable_test.rb +28 -0
  152. data/test/lib/vedeu/storage/associative_store_test.rb +7 -0
  153. data/test/lib/vedeu/storage/conveyor_store_test.rb +7 -0
  154. data/test/lib/vedeu/storage/fifo_store_test.rb +7 -0
  155. data/test/support/helpers/model_test_class.rb +6 -2
  156. data/test/test_helper.rb +2 -0
  157. data/vedeu.gemspec +3 -2
  158. metadata +23 -6
  159. data/test/lib/vedeu/output/renderers/escape_sequence_renderer_test.rb +0 -46
@@ -4,22 +4,26 @@ module Vedeu
4
4
 
5
5
  describe Buffer do
6
6
 
7
- let(:described) { Vedeu::Buffer }
8
- let(:instance) { described.new(attributes) }
9
- let(:attributes) {
7
+ let(:described) { Vedeu::Buffer }
8
+ let(:instance) { described.new(attributes) }
9
+ let(:attributes) {
10
10
  {
11
- name: _name,
12
- back: back,
13
- front: front,
14
- previous: previous,
11
+ name: _name,
12
+ back: back,
13
+ front: front,
14
+ previous: previous,
15
15
  }
16
16
  }
17
- let(:_name) { 'krypton' }
18
- let(:back) {}
19
- let(:front) {}
20
- let(:previous) {}
21
-
22
- before { Vedeu.stubs(:trigger) }
17
+ let(:_name) { 'krypton' }
18
+ let(:back) {}
19
+ let(:front) {}
20
+ let(:previous) {}
21
+ let(:interface) {}
22
+
23
+ before do
24
+ Vedeu.stubs(:trigger)
25
+ # Vedeu.interfaces.stubs(:by_name).returns(interface)
26
+ end
23
27
 
24
28
  describe '#initialize' do
25
29
  it { instance.must_be_instance_of(described) }
@@ -61,6 +65,37 @@ module Vedeu
61
65
  end
62
66
  end
63
67
 
68
+ describe '#clear' do
69
+ subject { instance.clear }
70
+
71
+ context 'when the clear buffer is empty' do
72
+ end
73
+
74
+ context 'when the clear buffer is not empty' do
75
+ end
76
+ end
77
+
78
+ describe '#hide' do
79
+ subject { instance.hide }
80
+
81
+ context 'when the interface is visible' do
82
+ end
83
+
84
+ context 'when the interface is not visible' do
85
+ it { subject.must_be_instance_of(NilClass) }
86
+ end
87
+ end
88
+
89
+ describe '#show' do
90
+ subject { instance.show }
91
+
92
+ context 'when the interface is visible' do
93
+ end
94
+
95
+ context 'when the interface is not visible' do
96
+ end
97
+ end
98
+
64
99
  # describe '#render' do
65
100
  # before { Vedeu::Output.stubs(:render) }
66
101
 
@@ -6,16 +6,17 @@ module Vedeu
6
6
 
7
7
  describe CLI do
8
8
 
9
- let(:described) { CLI.new(args) }
9
+ let(:described) { Vedeu::Config::CLI }
10
+ let(:instance) { described.new(args) }
10
11
  let(:args) { [] }
11
12
 
12
13
  before { Configuration.reset! }
13
14
  after { test_configuration }
14
15
 
15
16
  describe '#initialize' do
16
- it { described.must_be_instance_of(CLI) }
17
- it { described.instance_variable_get('@args').must_equal(args) }
18
- it { described.instance_variable_get('@options').must_equal({}) }
17
+ it { instance.must_be_instance_of(described) }
18
+ it { instance.instance_variable_get('@args').must_equal(args) }
19
+ it { instance.instance_variable_get('@options').must_equal({}) }
19
20
  end
20
21
 
21
22
  describe '#colour_mode' do
@@ -7,9 +7,20 @@ module Vedeu
7
7
  let(:described) { Vedeu::RefreshCursor }
8
8
  let(:instance) { described.new(_name) }
9
9
  let(:_name) { 'refresh_cursor' }
10
+ let(:expected) {}
11
+ let(:ox) { 0 }
12
+ let(:oy) { 0 }
10
13
 
11
14
  before do
12
- Vedeu::Terminal.stubs(:output)
15
+ Vedeu.geometry 'refresh_cursor' do
16
+ x 1
17
+ xn 3
18
+ y 1
19
+ yn 3
20
+ end
21
+ Vedeu::Cursor.new({ name: 'refresh_cursor', ox: ox, oy: oy }).store
22
+
23
+ Vedeu::Terminal.stubs(:output).returns(expected)
13
24
  end
14
25
 
15
26
  describe '#initialize' do
@@ -17,20 +28,31 @@ module Vedeu
17
28
  it { instance.instance_variable_get('@name').must_equal(_name) }
18
29
  end
19
30
 
20
- # describe '.render' do
21
- # subject { described.render(_name) }
22
-
23
- # it 'renders the cursor in the terminal' do
24
- # Vedeu::Terminal.expects(:output).with("\e[1;1H\e[?25l")
25
- # subject
26
- # end
27
-
28
- # context 'when the view should be refreshed' do
29
- # end
30
-
31
- # context 'when the view should not be refreshed' do
32
- # end
33
- # end
31
+ describe '.render' do
32
+ subject { described.render(_name) }
33
+
34
+ it 'renders the cursor in the terminal' do
35
+ Vedeu::Terminal.expects(:output).with("\e[1;1H\e[?25l")
36
+ subject
37
+ end
38
+
39
+ context 'when the cursors offset position is outside the viewable area' do
40
+ let(:ox) { 3 }
41
+ let(:oy) { 3 }
42
+
43
+ it 'refreshes the view' do
44
+ Vedeu::Refresh.expects(:by_name)
45
+ subject
46
+ end
47
+ end
48
+
49
+ context 'when the cursors offset position is inside the viewable area' do
50
+ it 'does not refresh the view' do
51
+ Vedeu::Refresh.expects(:by_name).never
52
+ subject
53
+ end
54
+ end
55
+ end
34
56
 
35
57
  end # RefreshCursor
36
58
 
@@ -15,6 +15,7 @@ module Vedeu
15
15
  it do
16
16
  subject.instance_variable_get('@application').must_equal(application)
17
17
  end
18
+ it { subject.instance_variable_get('@pid').must_equal(nil) }
18
19
  end
19
20
 
20
21
  end # Subprocess
@@ -24,13 +24,8 @@ module Vedeu
24
24
  end
25
25
  end
26
26
 
27
- describe '.use' do
27
+ describe '#use' do
28
28
  context 'when the model exists' do
29
- context 'and the attribute exists' do
30
- end
31
-
32
- context 'but the attribute does not exist' do
33
- end
34
29
  end
35
30
 
36
31
  context 'when the model does not exist' do
@@ -19,6 +19,17 @@ module Vedeu
19
19
  it { subject; described.instance_variable_get('@loop').must_equal(false) }
20
20
  end
21
21
 
22
+ describe '.safe_exit_point!' do
23
+ subject { described.safe_exit_point! }
24
+
25
+ context 'when the application has started' do
26
+ end
27
+
28
+ context 'when the application has not started' do
29
+ it { Vedeu.expects(:trigger); subject }
30
+ end
31
+ end
32
+
22
33
  end # MainLoop
23
34
 
24
35
  end # Vedeu
@@ -6,6 +6,33 @@ module Vedeu
6
6
 
7
7
  describe Interface do
8
8
 
9
+ let(:described) { Vedeu::Null::Interface }
10
+ let(:instance) { described.new(_name) }
11
+ let(:_name) {}
12
+
13
+ describe '#initialize' do
14
+ it { instance.must_be_instance_of(Vedeu::Null::Interface) }
15
+ it { instance.instance_variable_get('@name').must_equal(_name) }
16
+ end
17
+
18
+ describe '#attributes' do
19
+ subject { instance.attributes }
20
+
21
+ it { subject.must_be_instance_of(Hash) }
22
+ end
23
+
24
+ describe '#store' do
25
+ subject { instance.store }
26
+
27
+ it { subject.must_be_instance_of(Vedeu::Null::Interface) }
28
+ end
29
+
30
+ describe '#visible?' do
31
+ subject { instance.visible? }
32
+
33
+ it { subject.must_be_instance_of(FalseClass) }
34
+ end
35
+
9
36
  end # Interface
10
37
 
11
38
  end # Null
@@ -24,16 +24,23 @@ module Vedeu
24
24
  subject { described.render(content) }
25
25
 
26
26
  context 'when DRb is enabled' do
27
- let(:drb) { true }
28
-
29
- it { }
30
- end
31
-
32
- context 'when DRb is not enabled' do
33
- # it 'sends the rendered interface to the Terminal' do
34
- # Vedeu::Renderers::Terminal.expects(:render)
35
- # subject.must_be_instance_of(Array)
36
- # end
27
+ let(:drb) { true }
28
+ let(:virtual_buffer) { [] }
29
+
30
+ before do
31
+ Vedeu::Renderers::HTML.stubs(:to_file)
32
+ Vedeu::VirtualBuffer.stubs(:retrieve).returns(virtual_buffer)
33
+ end
34
+
35
+ it {
36
+ Vedeu.expects(:trigger).with(:_drb_store_output_, content)
37
+ subject
38
+ }
39
+
40
+ it 'writes the virtual buffer to a file' do
41
+ Vedeu::Renderers::HTML.expects(:to_file).with(virtual_buffer)
42
+ subject
43
+ end
37
44
  end
38
45
 
39
46
  it { Vedeu.renderers.expects(:render).with(content); subject }
@@ -20,40 +20,68 @@ module Vedeu
20
20
  class PresentationTestClass
21
21
  include Presentation
22
22
 
23
+ attr_reader :attributes
24
+
25
+ def initialize(attributes = {})
26
+ @attributes = attributes
27
+ end
28
+
23
29
  def parent
24
30
  ParentPresentationTestClass.new
25
31
  end
26
32
 
27
- def attributes
28
- {
29
- colour: { background: '#000033', foreground: '#aadd00' },
30
- style: ['bold']
31
- }
32
- end
33
33
  end # PresentationTestClass
34
34
 
35
35
  describe Presentation do
36
36
 
37
- let(:receiver) { PresentationTestClass.new }
37
+ let(:receiver) { PresentationTestClass.new(attributes) }
38
+ let(:attributes) {
39
+ {
40
+ colour: { background: background, foreground: foreground },
41
+ style: ['bold']
42
+ }
43
+ }
44
+ let(:background) { '#000033' }
45
+ let(:foreground) { '#aadd00' }
38
46
 
39
47
  describe '#background' do
40
48
  subject { receiver.background }
41
49
 
42
50
  it { subject.must_be_instance_of(Vedeu::Background) }
51
+ it { subject.colour.must_equal('#000033') }
52
+
53
+ context 'no background value' do
54
+ let(:background) {}
55
+
56
+ it { subject.must_be_instance_of(Vedeu::Background) }
57
+ it { subject.colour.must_equal('') }
58
+ end
43
59
  end
44
60
 
45
61
  describe '#foreground' do
46
62
  subject { receiver.foreground }
47
63
 
48
64
  it { subject.must_be_instance_of(Vedeu::Foreground) }
65
+ it { subject.colour.must_equal('#aadd00') }
66
+
67
+ context 'no foreground value' do
68
+ let(:foreground) {}
69
+
70
+ it { subject.must_be_instance_of(Vedeu::Foreground) }
71
+ it { subject.colour.must_equal('') }
72
+ end
49
73
  end
50
74
 
51
75
  describe '#parent_background' do
52
76
  subject { receiver.parent_background }
77
+
78
+ it { subject.must_be_instance_of(Vedeu::Background) }
53
79
  end
54
80
 
55
81
  describe '#parent_foreground' do
56
82
  subject { receiver.parent_foreground }
83
+
84
+ it { subject.must_be_instance_of(Vedeu::Foreground) }
57
85
  end
58
86
 
59
87
  describe '#colour' do
@@ -0,0 +1,50 @@
1
+ require 'test_helper'
2
+
3
+ module Vedeu
4
+
5
+ module Renderers
6
+
7
+ describe EscapeSequence do
8
+
9
+ let(:described) { Vedeu::Renderers::EscapeSequence }
10
+ let(:instance) { described.new(output) }
11
+ let(:output) {}
12
+
13
+ describe '#initialize' do
14
+ it { instance.must_be_instance_of(described) }
15
+ it { instance.instance_variable_get('@output').must_equal(output) }
16
+ end
17
+
18
+ describe '.render' do
19
+ subject { described.render(output) }
20
+
21
+ it { subject.must_be_instance_of(String) }
22
+
23
+ context 'when there is no output' do
24
+ it { subject.must_equal('') }
25
+ end
26
+
27
+ context 'when there is output' do
28
+ let(:output) {
29
+ [
30
+ Vedeu::Char.new(value: 't', colour: { background: '#ff0000', foreground: '#ffffff' }),
31
+ Vedeu::Char.new(value: 'e', colour: { background: '#ffff00', foreground: '#000000' }),
32
+ Vedeu::Char.new(value: 's', colour: { background: '#00ff00', foreground: '#000000' }),
33
+ Vedeu::Char.new(value: 't', colour: { background: '#00ffff', foreground: '#000000' }),
34
+ ]
35
+ }
36
+
37
+ it { subject.must_equal(
38
+ "\\e[38;2;255;255;255m\\e[48;2;255;0;0mt\n" \
39
+ "\\e[38;2;0;0;0m\\e[48;2;255;255;0me\n" \
40
+ "\\e[38;2;0;0;0m\\e[48;2;0;255;0ms\n" \
41
+ "\\e[38;2;0;0;0m\\e[48;2;0;255;255mt\n")
42
+ }
43
+ end
44
+ end
45
+
46
+ end # EscapeSequence
47
+
48
+ end # Renderers
49
+
50
+ end # Vedeu
@@ -2,46 +2,50 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe Renderers::File do
6
-
7
- let(:described) { Vedeu::Renderers::File }
8
- let(:instance) { described.new(output, options) }
9
- let(:output) {}
10
- let(:options) {
11
- {
12
- timestamp: timestamp
5
+ module Renderers
6
+
7
+ describe File do
8
+
9
+ let(:described) { Vedeu::Renderers::File }
10
+ let(:instance) { described.new(output, options) }
11
+ let(:output) {}
12
+ let(:options) {
13
+ {
14
+ timestamp: timestamp
15
+ }
13
16
  }
14
- }
15
- let(:timestamp) { true }
17
+ let(:timestamp) { true }
18
+
19
+ describe '#initialize' do
20
+ it { instance.must_be_instance_of(described) }
21
+ it { instance.instance_variable_get('@output').must_equal(output) }
22
+ it { instance.instance_variable_get('@options').must_equal(options) }
23
+ end
16
24
 
17
- describe '#initialize' do
18
- it { instance.must_be_instance_of(described) }
19
- it { instance.instance_variable_get('@output').must_equal(output) }
20
- it { instance.instance_variable_get('@options').must_equal(options) }
21
- end
25
+ describe '.render' do
26
+ let(:_time) { Time.new(2015, 4, 12, 20, 05) }
22
27
 
23
- describe '.render' do
24
- let(:_time) { Time.new(2015, 4, 12, 20, 05) }
28
+ before { File.stubs(:open) }
25
29
 
26
- before { File.stubs(:open) }
30
+ subject { described.render(output, options) }
27
31
 
28
- subject { described.render(output, options) }
32
+ it { subject.must_be_instance_of(String) }
29
33
 
30
- it { subject.must_be_instance_of(String) }
34
+ # context 'when the timestamp option is true' do
35
+ # before { Time.stubs(:now).returns(_time) }
31
36
 
32
- # context 'when the timestamp option is true' do
33
- # before { Time.stubs(:now).returns(_time) }
37
+ # it { File.expects(:open).with('/tmp/out_1428865500.0', 'w'); subject }
38
+ # end
34
39
 
35
- # it { File.expects(:open).with('/tmp/out_1428865500.0', 'w'); subject }
36
- # end
40
+ # context 'when the timestamp option is false' do
41
+ # let(:timestamp) { false }
37
42
 
38
- # context 'when the timestamp option is false' do
39
- # let(:timestamp) { false }
43
+ # it { File.expects(:open).with('/tmp/out', 'w'); subject }
44
+ # end
45
+ end
40
46
 
41
- # it { File.expects(:open).with('/tmp/out', 'w'); subject }
42
- # end
43
- end
47
+ end # File
44
48
 
45
- end # Renderers::File
49
+ end # Renderers
46
50
 
47
51
  end # Vedeu
@@ -2,85 +2,89 @@ require 'test_helper'
2
2
 
3
3
  module Vedeu
4
4
 
5
- describe Renderers::HTML do
5
+ module Renderers
6
6
 
7
- let(:described) { Vedeu::Renderers::HTML }
8
- let(:instance) { described.new(output) }
9
- let(:output) {}
7
+ describe HTML do
10
8
 
11
- describe '#initialize' do
12
- it { instance.must_be_instance_of(described) }
13
- it { instance.instance_variable_get('@output').must_equal(output) }
14
- end
9
+ let(:described) { Vedeu::Renderers::HTML }
10
+ let(:instance) { described.new(output) }
11
+ let(:output) {}
15
12
 
16
- describe '.render' do
17
- before { File.stubs(:open) }
13
+ describe '#initialize' do
14
+ it { instance.must_be_instance_of(described) }
15
+ it { instance.instance_variable_get('@output').must_equal(output) }
16
+ end
17
+
18
+ describe '.render' do
19
+ before { ::File.stubs(:open) }
18
20
 
19
- subject { described.render(output) }
21
+ subject { described.render(output) }
20
22
 
21
- it { subject.must_be_instance_of(String) }
22
- end
23
+ it { subject.must_be_instance_of(String) }
24
+ end
23
25
 
24
- describe '.to_file' do
25
- before { File.stubs(:open) }
26
+ describe '.to_file' do
27
+ before { ::File.stubs(:open) }
26
28
 
27
- subject { described.to_file(output, path) }
29
+ subject { described.to_file(output, path) }
28
30
 
29
- context 'when a path is given' do
30
- let(:path) { '/tmp/test_vedeu_html_renderer.html' }
31
+ context 'when a path is given' do
32
+ let(:path) { '/tmp/test_vedeu_html_renderer.html' }
31
33
 
32
- it do
33
- File.expects(:open)
34
- subject
34
+ it do
35
+ ::File.expects(:open)
36
+ subject
37
+ end
35
38
  end
36
- end
37
39
 
38
- context 'when a path is not given' do
39
- let(:path) {}
40
- let(:_time) { Time.new(2015, 4, 12, 16, 55) }
40
+ context 'when a path is not given' do
41
+ let(:path) {}
42
+ let(:_time) { Time.new(2015, 4, 12, 16, 55) }
41
43
 
42
- before { Time.stubs(:now).returns(_time) }
44
+ before { Time.stubs(:now).returns(_time) }
43
45
 
44
- it do
45
- File.expects(:open)#.with('/tmp/vedeu_html_1428854100.html', 'w')
46
- subject
46
+ it do
47
+ ::File.expects(:open)#.with('/tmp/vedeu_html_1428854100.html', 'w')
48
+ subject
49
+ end
47
50
  end
48
51
  end
49
- end
50
52
 
51
- describe '#html_body' do
52
- subject { instance.html_body }
53
+ describe '#html_body' do
54
+ subject { instance.html_body }
53
55
 
54
- it { subject.must_be_instance_of(String) }
56
+ it { subject.must_be_instance_of(String) }
55
57
 
56
- it { subject.must_equal('') }
58
+ it { subject.must_equal('') }
57
59
 
58
- context 'when there is output' do
59
- let(:output) {
60
- [
60
+ context 'when there is output' do
61
+ let(:output) {
61
62
  [
62
- Vedeu::Char.new(value: 't'),
63
- Vedeu::Char.new(value: 'e'),
64
- Vedeu::Char.new(value: 's'),
65
- Vedeu::Char.new(value: 't'),
63
+ [
64
+ Vedeu::Char.new(value: 't'),
65
+ Vedeu::Char.new(value: 'e'),
66
+ Vedeu::Char.new(value: 's'),
67
+ Vedeu::Char.new(value: 't'),
68
+ ]
66
69
  ]
67
- ]
68
- }
69
-
70
- it { subject.must_equal(
71
- "<tr>\n" \
72
- "<td style='background:#000;color:#222;border:1px #000 solid;'>" \
73
- "t</td>\n" \
74
- "<td style='background:#000;color:#222;border:1px #000 solid;'>" \
75
- "e</td>\n" \
76
- "<td style='background:#000;color:#222;border:1px #000 solid;'>" \
77
- "s</td>\n" \
78
- "<td style='background:#000;color:#222;border:1px #000 solid;'>" \
79
- "t</td>\n" \
80
- "</tr>\n") }
70
+ }
71
+
72
+ it { subject.must_equal(
73
+ "<tr>\n" \
74
+ "<td style='background:#000;color:#222;border:1px #000 solid;'>" \
75
+ "t</td>\n" \
76
+ "<td style='background:#000;color:#222;border:1px #000 solid;'>" \
77
+ "e</td>\n" \
78
+ "<td style='background:#000;color:#222;border:1px #000 solid;'>" \
79
+ "s</td>\n" \
80
+ "<td style='background:#000;color:#222;border:1px #000 solid;'>" \
81
+ "t</td>\n" \
82
+ "</tr>\n") }
83
+ end
81
84
  end
82
- end
83
85
 
84
- end # Renderers::HTML
86
+ end # HTML
87
+
88
+ end # Renderers
85
89
 
86
90
  end # Vedeu