vedeu 0.0.39 → 0.0.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -30
  3. data/Rakefile +8 -9
  4. data/bin/log +13 -0
  5. data/deps.md +11 -95
  6. data/lib/vedeu.rb +14 -46
  7. data/lib/vedeu/application.rb +4 -8
  8. data/lib/vedeu/instrumentation.rb +111 -0
  9. data/lib/vedeu/launcher.rb +2 -2
  10. data/lib/vedeu/models/attributes/interface_collection.rb +2 -2
  11. data/lib/vedeu/models/attributes/line_collection.rb +2 -2
  12. data/lib/vedeu/models/attributes/stream_collection.rb +2 -2
  13. data/lib/vedeu/models/colour.rb +1 -1
  14. data/lib/vedeu/models/composition.rb +1 -1
  15. data/lib/vedeu/models/interface.rb +18 -10
  16. data/lib/vedeu/models/line.rb +3 -3
  17. data/lib/vedeu/models/presentation.rb +1 -1
  18. data/lib/vedeu/models/stream.rb +2 -2
  19. data/lib/vedeu/models/style.rb +1 -1
  20. data/lib/vedeu/output/render_interface.rb +1 -1
  21. data/lib/vedeu/{support → parsing}/compositor.rb +1 -1
  22. data/lib/vedeu/parsing/hash_parser.rb +1 -1
  23. data/lib/vedeu/parsing/parser.rb +6 -10
  24. data/lib/vedeu/{models/builders → support}/builder.rb +19 -9
  25. data/lib/vedeu/support/esc.rb +1 -1
  26. data/lib/vedeu/support/events.rb +15 -19
  27. data/lib/vedeu/support/geometry.rb +3 -3
  28. data/lib/vedeu/{input → support}/input.rb +6 -9
  29. data/lib/vedeu/support/menu.rb +3 -3
  30. data/lib/vedeu/support/persistence.rb +41 -0
  31. data/lib/vedeu/support/terminal.rb +1 -1
  32. data/test/example_app/lib/app.rb +85 -5
  33. data/test/lib/vedeu/application_test.rb +2 -2
  34. data/test/lib/vedeu/configuration_test.rb +2 -2
  35. data/test/lib/vedeu/launcher_test.rb +2 -2
  36. data/test/lib/vedeu/models/attributes/collection_test.rb +2 -2
  37. data/test/lib/vedeu/models/attributes/interface_collection_test.rb +4 -4
  38. data/test/lib/vedeu/models/attributes/line_collection_test.rb +3 -3
  39. data/test/lib/vedeu/models/attributes/stream_collection_test.rb +3 -3
  40. data/test/lib/vedeu/models/colour_test.rb +2 -2
  41. data/test/lib/vedeu/models/composition_test.rb +19 -19
  42. data/test/lib/vedeu/models/interface_test.rb +46 -34
  43. data/test/lib/vedeu/models/line_test.rb +2 -2
  44. data/test/lib/vedeu/models/presentation_test.rb +2 -2
  45. data/test/lib/vedeu/models/stream_test.rb +2 -2
  46. data/test/lib/vedeu/models/style_test.rb +31 -31
  47. data/test/lib/vedeu/output/clear_interface_test.rb +5 -5
  48. data/test/lib/vedeu/output/render_interface_test.rb +5 -6
  49. data/test/lib/vedeu/output/template.rb +2 -1
  50. data/test/lib/vedeu/{support → parsing}/compositor_test.rb +6 -4
  51. data/test/lib/vedeu/parsing/hash_parser_test.rb +2 -2
  52. data/test/lib/vedeu/parsing/json_parser_test.rb +2 -2
  53. data/test/lib/vedeu/parsing/parser_test.rb +6 -5
  54. data/test/lib/vedeu/parsing/text_adaptor_test.rb +2 -2
  55. data/test/lib/vedeu/{models/builders/interface_builder_test.rb → support/builder_test.rb} +10 -10
  56. data/test/lib/vedeu/support/esc_test.rb +2 -2
  57. data/test/lib/vedeu/support/events_test.rb +2 -2
  58. data/test/lib/vedeu/support/geometry_test.rb +2 -2
  59. data/test/lib/vedeu/{input → support}/input_test.rb +6 -7
  60. data/test/lib/vedeu/support/menu_test.rb +2 -2
  61. data/test/lib/vedeu/support/persistence_test.rb +55 -0
  62. data/test/lib/vedeu/support/queue_test.rb +2 -2
  63. data/test/lib/vedeu/support/terminal_test.rb +2 -2
  64. data/test/lib/vedeu/support/translator_test.rb +2 -2
  65. data/test/lib/vedeu/support/wordwrap_test.rb +2 -2
  66. data/test/lib/vedeu_test.rb +17 -2
  67. data/test/support/bench.rb +34 -0
  68. data/test/test_helper.rb +3 -11
  69. data/vedeu.gemspec +2 -2
  70. metadata +20 -44
  71. data/lib/vedeu/models/builders/command_builder.rb +0 -10
  72. data/lib/vedeu/models/builders/interface_builder.rb +0 -32
  73. data/lib/vedeu/models/command.rb +0 -23
  74. data/lib/vedeu/output/output.rb +0 -14
  75. data/lib/vedeu/process/process.rb +0 -51
  76. data/lib/vedeu/repository/command_repository.rb +0 -31
  77. data/lib/vedeu/repository/interface_repository.rb +0 -31
  78. data/lib/vedeu/repository/repository.rb +0 -41
  79. data/lib/vedeu/repository/storage.rb +0 -40
  80. data/lib/vedeu/support/exit.rb +0 -9
  81. data/test/lib/vedeu/models/builders/builder_test.rb +0 -11
  82. data/test/lib/vedeu/models/builders/command_builder_test.rb +0 -16
  83. data/test/lib/vedeu/models/command_test.rb +0 -40
  84. data/test/lib/vedeu/output/output_test.rb +0 -19
  85. data/test/lib/vedeu/process/process_test.rb +0 -71
  86. data/test/lib/vedeu/repository/command_repository_test.rb +0 -55
  87. data/test/lib/vedeu/repository/interface_repository_test.rb +0 -67
  88. data/test/lib/vedeu/repository/repository_test.rb +0 -81
  89. data/test/lib/vedeu/repository/storage_test.rb +0 -70
  90. data/test/lib/vedeu/support/exit_test.rb +0 -12
  91. data/test/support/dummy_command.rb +0 -9
@@ -1,6 +1,6 @@
1
1
  require 'io/console'
2
2
 
3
- require_relative 'esc'
3
+ require 'vedeu/support/esc'
4
4
 
5
5
  module Vedeu
6
6
  module Terminal
@@ -27,6 +27,27 @@ module Example
27
27
  end
28
28
  end
29
29
 
30
+ class MenuCommand
31
+ def self.dispatch
32
+ @command ||= new
33
+ @command.dispatch
34
+ end
35
+
36
+ def initialize; end
37
+
38
+ def dispatch
39
+ Vedeu::Parser.parse({ 'example' => render })
40
+ end
41
+
42
+ def render
43
+ menu.render.map { |item| "#{item}\n" }
44
+ end
45
+
46
+ def menu
47
+ @_menu ||= Vedeu::Menu.new(['hydrogen', 'carbon', 'nitrogen', 'oxygen'])
48
+ end
49
+ end
50
+
30
51
  class App
31
52
  include Vedeu
32
53
 
@@ -36,7 +57,7 @@ module Example
36
57
  colour foreground: '#ff0000', background: '#000000'
37
58
  cursor false
38
59
  width 40
39
- height 3
60
+ height 5
40
61
  centred true
41
62
  end
42
63
 
@@ -58,18 +79,77 @@ module Example
58
79
  keypress 't'
59
80
  end
60
81
 
82
+ # command 'menu' do
83
+ # entity MenuCommand
84
+ # keyword 'menu'
85
+ # keypress 'm'
86
+ # end
87
+
61
88
  command 'exit' do
62
89
  entity Vedeu::Exit
63
90
  keyword 'exit'
64
91
  keypress 'q'
65
92
  end
66
93
 
94
+ event :show_menu do
95
+ MenuCommand.dispatch
96
+
97
+ # Vedeu::Output.render
98
+ end
99
+
67
100
  event :key do |key|
68
101
  case key
69
- when 'v' then puts "v was pressed."
70
- when :f1 then puts "F1 was pressed."
71
- when :f2 then run(:some_event, [:args, :go, :here])
72
- when 'x' then run(:_exit_)
102
+ when "v" then puts "v was pressed."
103
+ when :f1 then puts "F1 was pressed."
104
+ when :f2 then run(:some_event, [:args, :go, :here])
105
+ when "x" then run(:_exit_)
106
+
107
+ when :up then
108
+ run(:menu_prev)
109
+ run(:menu_render)
110
+ run(:show_menu)
111
+ run(:refresh)
112
+
113
+ when :down then
114
+ run(:menu_next)
115
+ run(:menu_render)
116
+ run(:show_menu)
117
+ run(:refresh)
118
+
119
+ when :page_up then
120
+ run(:menu_top)
121
+ run(:menu_render)
122
+ run(:show_menu)
123
+ run(:refresh)
124
+
125
+ when :page_down then
126
+ run(:menu_bottom)
127
+ run(:menu_render)
128
+ run(:show_menu)
129
+ run(:refresh)
130
+
131
+ when :enter then
132
+ run(:menu_select)
133
+ run(:app_select_item, m)
134
+ run(:menu_render)
135
+ run(:show_menu)
136
+ run(:refresh)
137
+
138
+ when :backspace then
139
+ run(:menu_deselect)
140
+ run(:menu_render)
141
+ run(:show_menu)
142
+ run(:refresh)
143
+
144
+ when "r" then
145
+ run(:menu_render)
146
+ run(:show_menu)
147
+ run(:refresh)
148
+
149
+ when "m" then
150
+ run(:show_menu)
151
+ run(:refresh)
152
+
73
153
  else
74
154
  end
75
155
  end
@@ -1,5 +1,5 @@
1
- require_relative '../../test_helper'
2
- require_relative '../../../lib/vedeu/application'
1
+ require 'test_helper'
2
+ require 'vedeu/application'
3
3
 
4
4
  module Vedeu
5
5
  describe Application do
@@ -1,5 +1,5 @@
1
- require_relative '../../test_helper'
2
- require_relative '../../../lib/vedeu/configuration'
1
+ require 'test_helper'
2
+ require 'vedeu/configuration'
3
3
 
4
4
  module Vedeu
5
5
  describe Configuration do
@@ -1,5 +1,5 @@
1
- require_relative '../../test_helper'
2
- require_relative '../../../lib/vedeu/launcher'
1
+ require 'test_helper'
2
+ require 'vedeu/launcher'
3
3
 
4
4
  module Vedeu
5
5
  describe Launcher do
@@ -1,5 +1,5 @@
1
- require_relative '../../../../test_helper'
2
- require_relative '../../../../../lib/vedeu/models/attributes/collection'
1
+ require 'test_helper'
2
+ require 'vedeu/models/attributes/collection'
3
3
 
4
4
  module Vedeu
5
5
  class TestClass
@@ -1,11 +1,11 @@
1
- require_relative '../../../../test_helper'
2
- require_relative '../../../../../lib/vedeu/models/attributes/interface_collection'
3
- require_relative '../../../../../lib/vedeu/models/composition'
1
+ require 'test_helper'
2
+ require 'vedeu/models/attributes/interface_collection'
3
+ require 'vedeu/models/composition'
4
4
 
5
5
  module Vedeu
6
6
  describe InterfaceCollection do
7
7
  describe '#coerce' do
8
- before { InterfaceRepository.reset }
8
+ before { Persistence.reset }
9
9
 
10
10
  it 'returns an empty collection when there are no interfaces' do
11
11
  composition = Composition.new
@@ -1,6 +1,6 @@
1
- require_relative '../../../../test_helper'
2
- require_relative '../../../../../lib/vedeu/models/attributes/line_collection'
3
- require_relative '../../../../../lib/vedeu/models/interface'
1
+ require 'test_helper'
2
+ require 'vedeu/models/attributes/line_collection'
3
+ require 'vedeu/models/interface'
4
4
 
5
5
  module Vedeu
6
6
  describe LineCollection do
@@ -1,6 +1,6 @@
1
- require_relative '../../../../test_helper'
2
- require_relative '../../../../../lib/vedeu/models/attributes/stream_collection'
3
- require_relative '../../../../../lib/vedeu/models/line'
1
+ require 'test_helper'
2
+ require 'vedeu/models/attributes/stream_collection'
3
+ require 'vedeu/models/line'
4
4
 
5
5
  module Vedeu
6
6
  describe StreamCollection do
@@ -1,5 +1,5 @@
1
- require_relative '../../../test_helper'
2
- require_relative '../../../../lib/vedeu/models/colour'
1
+ require 'test_helper'
2
+ require 'vedeu/models/colour'
3
3
 
4
4
  module Vedeu
5
5
  describe Colour do
@@ -1,6 +1,6 @@
1
- require_relative '../../../test_helper'
2
- require_relative '../../../../lib/vedeu/models/composition'
3
- require_relative '../../../../lib/vedeu/repository/interface_repository'
1
+ require 'test_helper'
2
+ require 'vedeu/models/composition'
3
+ require 'vedeu/support/persistence'
4
4
 
5
5
  module Vedeu
6
6
  describe Composition do
@@ -36,13 +36,13 @@ module Vedeu
36
36
  ]
37
37
  }
38
38
 
39
- Composition.new(attributes).to_json.must_equal("{\"interfaces\":[{\"colour\":{\"foreground\":\"\#ffff33\",\"background\":\"\#ffff77\"},\"style\":\"\",\"name\":\"Composition#to_json\",\"lines\":[],\"y\":1,\"x\":1,\"z\":1,\"width\":5,\"height\":5,\"cursor\":true}]}")
39
+ Composition.new(attributes).to_json.must_equal("{\"interfaces\":[{\"colour\":{\"foreground\":\"\#ffff33\",\"background\":\"\#ffff77\"},\"style\":\"\",\"name\":\"Composition#to_json\",\"lines\":[],\"y\":1,\"x\":1,\"width\":5,\"height\":5,\"cursor\":true}]}")
40
40
  end
41
41
  end
42
42
 
43
43
  describe '#to_s' do
44
44
  it 'returns the stringified content for a single interface, single line, single stream' do
45
- InterfaceRepository.create({ name: 'int1_lin1_str1', y: 3, x: 3, width: 10, height: 3 })
45
+ Persistence.create({ name: 'int1_lin1_str1', y: 3, x: 3, width: 10, height: 3 })
46
46
  json = File.read('test/support/json/int1_lin1_str1.json')
47
47
  attributes = JSON.load(json, nil, symbolize_names: true)
48
48
 
@@ -55,7 +55,7 @@ module Vedeu
55
55
  end
56
56
 
57
57
  it 'returns the stringified content for a single interface, single line, multiple streams' do
58
- InterfaceRepository.create({ name: 'int1_lin1_str3', y: 3, x: 3, width: 10, height: 3 })
58
+ Persistence.create({ name: 'int1_lin1_str3', y: 3, x: 3, width: 10, height: 3 })
59
59
  json = File.read('test/support/json/int1_lin1_str3.json')
60
60
  attributes = JSON.load(json, nil, symbolize_names: true)
61
61
 
@@ -68,7 +68,7 @@ module Vedeu
68
68
  end
69
69
 
70
70
  it 'returns the stringified content for a single interface, multiple lines, single stream' do
71
- InterfaceRepository.create({ name: 'int1_lin2_str1', y: 3, x: 3, width: 10, height: 3 })
71
+ Persistence.create({ name: 'int1_lin2_str1', y: 3, x: 3, width: 10, height: 3 })
72
72
  json = File.read('test/support/json/int1_lin2_str1.json')
73
73
  attributes = JSON.load(json, nil, symbolize_names: true)
74
74
 
@@ -82,7 +82,7 @@ module Vedeu
82
82
  end
83
83
 
84
84
  it 'returns the stringified content for a single interface, multiple lines, multiple streams' do
85
- InterfaceRepository.create({ name: 'int1_lin2_str3', y: 3, x: 3, width: 10, height: 3 })
85
+ Persistence.create({ name: 'int1_lin2_str3', y: 3, x: 3, width: 10, height: 3 })
86
86
  json = File.read('test/support/json/int1_lin2_str3.json')
87
87
  attributes = JSON.load(json, nil, symbolize_names: true)
88
88
 
@@ -98,7 +98,7 @@ module Vedeu
98
98
  it 'returns the stringified content for a single interface, multiple lines, multiple streams, streams contain styles' do
99
99
  json = File.read('test/support/json/int1_lin2_str3_styles.json')
100
100
  attributes = JSON.load(json, nil, symbolize_names: true)
101
- InterfaceRepository.create({ name: 'int1_lin2_str3_styles', y: 3, x: 3, width: 10, height: 3 })
101
+ Persistence.create({ name: 'int1_lin2_str3_styles', y: 3, x: 3, width: 10, height: 3 })
102
102
 
103
103
  Composition.new(attributes).to_s.must_equal(
104
104
  "\e[3;3H \e[3;3H" \
@@ -109,8 +109,8 @@ module Vedeu
109
109
  end
110
110
 
111
111
  it 'returns the stringified content for multiple interfaces, single line, single stream' do
112
- InterfaceRepository.create({ name: 'int2_lin1_str1_1', y: 3, x: 3, width: 10, height: 3 })
113
- InterfaceRepository.create({ name: 'int2_lin1_str1_2', y: 6, x: 6, width: 10, height: 3 })
112
+ Persistence.create({ name: 'int2_lin1_str1_1', y: 3, x: 3, width: 10, height: 3 })
113
+ Persistence.create({ name: 'int2_lin1_str1_2', y: 6, x: 6, width: 10, height: 3 })
114
114
  json = File.read('test/support/json/int2_lin1_str1.json')
115
115
  attributes = JSON.load(json, nil, symbolize_names: true)
116
116
 
@@ -127,8 +127,8 @@ module Vedeu
127
127
  end
128
128
 
129
129
  it 'returns the stringified content for multiple interfaces, single line, multiple streams' do
130
- InterfaceRepository.create({ name: 'int2_lin1_str3_1', y: 3, x: 3, width: 10, height: 3 })
131
- InterfaceRepository.create({ name: 'int2_lin1_str3_2', y: 6, x: 6, width: 10, height: 3 })
130
+ Persistence.create({ name: 'int2_lin1_str3_1', y: 3, x: 3, width: 10, height: 3 })
131
+ Persistence.create({ name: 'int2_lin1_str3_2', y: 6, x: 6, width: 10, height: 3 })
132
132
  json = File.read('test/support/json/int2_lin1_str3.json')
133
133
  attributes = JSON.load(json, nil, symbolize_names: true)
134
134
 
@@ -145,8 +145,8 @@ module Vedeu
145
145
  end
146
146
 
147
147
  it 'returns the stringified content for multiple interfaces, multiple lines, single stream' do
148
- InterfaceRepository.create({ name: 'int2_lin2_str1_1', y: 3, x: 3, width: 10, height: 3 })
149
- InterfaceRepository.create({ name: 'int2_lin2_str1_2', y: 6, x: 6, width: 10, height: 3 })
148
+ Persistence.create({ name: 'int2_lin2_str1_1', y: 3, x: 3, width: 10, height: 3 })
149
+ Persistence.create({ name: 'int2_lin2_str1_2', y: 6, x: 6, width: 10, height: 3 })
150
150
  json = File.read('test/support/json/int2_lin2_str1.json')
151
151
  attributes = JSON.load(json, nil, symbolize_names: true)
152
152
 
@@ -165,8 +165,8 @@ module Vedeu
165
165
  end
166
166
 
167
167
  it 'returns the stringified content for multiple interfaces, multiple lines, multiple streams' do
168
- InterfaceRepository.create({ name: 'int2_lin2_str3_1', y: 3, x: 3, width: 10, height: 3 })
169
- InterfaceRepository.create({ name: 'int2_lin2_str3_2', y: 6, x: 6, width: 10, height: 3 })
168
+ Persistence.create({ name: 'int2_lin2_str3_1', y: 3, x: 3, width: 10, height: 3 })
169
+ Persistence.create({ name: 'int2_lin2_str3_2', y: 6, x: 6, width: 10, height: 3 })
170
170
  json = File.read('test/support/json/int2_lin2_str3.json')
171
171
  attributes = JSON.load(json, nil, symbolize_names: true)
172
172
 
@@ -185,8 +185,8 @@ module Vedeu
185
185
  end
186
186
 
187
187
  it 'returns the stringified content for multiple interfaces, multiple lines, multiple streams, streams contain styles' do
188
- InterfaceRepository.create({ name: 'int2_lin2_str3_styles_1', y: 3, x: 3, width: 10, height: 3 })
189
- InterfaceRepository.create({ name: 'int2_lin2_str3_styles_2', y: 6, x: 6, width: 10, height: 3 })
188
+ Persistence.create({ name: 'int2_lin2_str3_styles_1', y: 3, x: 3, width: 10, height: 3 })
189
+ Persistence.create({ name: 'int2_lin2_str3_styles_2', y: 6, x: 6, width: 10, height: 3 })
190
190
  json = File.read('test/support/json/int2_lin2_str3_styles.json')
191
191
  attributes = JSON.load(json, nil, symbolize_names: true)
192
192
 
@@ -1,5 +1,5 @@
1
- require_relative '../../../test_helper'
2
- require_relative '../../../../lib/vedeu/models/interface'
1
+ require 'test_helper'
2
+ require 'vedeu/models/interface'
3
3
 
4
4
  module Vedeu
5
5
  describe Interface do
@@ -13,7 +13,6 @@ module Vedeu
13
13
  },
14
14
  y: 3,
15
15
  x: 5,
16
- z: 2,
17
16
  width: 10,
18
17
  height: 15,
19
18
  current: "\e[1;1H#initialize"
@@ -42,11 +41,6 @@ module Vedeu
42
41
  Interface.new.x.must_equal(1)
43
42
  end
44
43
 
45
- it 'has a z attribute' do
46
- interface.z.must_equal(2)
47
- Interface.new.z.must_equal(1)
48
- end
49
-
50
44
  it 'has a width attribute' do
51
45
  interface.width.must_equal(10)
52
46
  end
@@ -71,7 +65,19 @@ module Vedeu
71
65
 
72
66
  describe '#enqueue' do
73
67
  it 'delegates to the Queue class to enqueue itself' do
74
- skip
68
+ Queue.reset
69
+ interface = Interface.new({
70
+ name: 'Interface#enqueue',
71
+ width: 5,
72
+ height: 2,
73
+ lines: [ { streams: { text: 'a8f39' } } ]
74
+ })
75
+ interface.enqueue
76
+ interface.dequeue.must_equal(
77
+ "\e[1;1H \e[1;1H" \
78
+ "\e[2;1H \e[2;1H" \
79
+ "\e[1;1Ha8f39"
80
+ )
75
81
  end
76
82
  end
77
83
 
@@ -112,12 +118,14 @@ module Vedeu
112
118
  }
113
119
 
114
120
  it 'returns a blank interface when there is no content to display (initial state)' do
115
- Interface.new(attributes).refresh.must_equal(
116
- "\e[38;5;196m\e[48;5;16m" \
117
- "\e[1;1H \e[1;1H" \
118
- "\e[2;1H \e[2;1H" \
119
- "\e[3;1H \e[3;1H"
120
- )
121
+ Terminal.stub(:output, nil) do
122
+ Interface.new(attributes).refresh.must_equal(
123
+ "\e[38;5;196m\e[48;5;16m" \
124
+ "\e[1;1H \e[1;1H" \
125
+ "\e[2;1H \e[2;1H" \
126
+ "\e[3;1H \e[3;1H"
127
+ )
128
+ end
121
129
  end
122
130
 
123
131
  it 'returns the fresh content when content is queued up to be displayed' do
@@ -138,15 +146,17 @@ module Vedeu
138
146
  interface = Interface.new(attributes)
139
147
  interface.enqueue
140
148
 
141
- interface.refresh.must_equal(
142
- "\e[38;5;196m\e[48;5;16m" \
143
- "\e[1;1H \e[1;1H" \
144
- "\e[2;1H \e[2;1H" \
145
- "\e[3;1H \e[3;1H" \
146
- "\e[1;1H#refresh" \
147
- "\e[2;1H#refresh" \
148
- "\e[3;1H#refresh"
149
- )
149
+ Terminal.stub(:output, nil) do
150
+ interface.refresh.must_equal(
151
+ "\e[38;5;196m\e[48;5;16m" \
152
+ "\e[1;1H \e[1;1H" \
153
+ "\e[2;1H \e[2;1H" \
154
+ "\e[3;1H \e[3;1H" \
155
+ "\e[1;1H#refresh" \
156
+ "\e[2;1H#refresh" \
157
+ "\e[3;1H#refresh"
158
+ )
159
+ end
150
160
  end
151
161
 
152
162
  it 'returns the previously shown content when there is stale content from last run' do
@@ -169,15 +179,17 @@ module Vedeu
169
179
  "\e[2;1H#refresh" \
170
180
  "\e[3;1H#refresh"
171
181
 
172
- interface.refresh.must_equal(
173
- "\e[38;5;196m\e[48;5;16m" \
174
- "\e[1;1H \e[1;1H" \
175
- "\e[2;1H \e[2;1H" \
176
- "\e[3;1H \e[3;1H" \
177
- "\e[1;1H#refresh" \
178
- "\e[2;1H#refresh" \
179
- "\e[3;1H#refresh"
180
- )
182
+ Terminal.stub(:output, nil) do
183
+ interface.refresh.must_equal(
184
+ "\e[38;5;196m\e[48;5;16m" \
185
+ "\e[1;1H \e[1;1H" \
186
+ "\e[2;1H \e[2;1H" \
187
+ "\e[3;1H \e[3;1H" \
188
+ "\e[1;1H#refresh" \
189
+ "\e[2;1H#refresh" \
190
+ "\e[3;1H#refresh"
191
+ )
192
+ end
181
193
  end
182
194
  end
183
195
 
@@ -212,7 +224,7 @@ module Vedeu
212
224
  },
213
225
  width: 3,
214
226
  height: 3
215
- }).to_json.must_equal("{\"colour\":{\"foreground\":\"#ff0000\",\"background\":\"#000000\"},\"style\":\"\",\"name\":\"#to_json\",\"lines\":[],\"y\":1,\"x\":1,\"z\":1,\"width\":3,\"height\":3,\"cursor\":true}")
227
+ }).to_json.must_equal("{\"colour\":{\"foreground\":\"#ff0000\",\"background\":\"#000000\"},\"style\":\"\",\"name\":\"#to_json\",\"lines\":[],\"y\":1,\"x\":1,\"width\":3,\"height\":3,\"cursor\":true}")
216
228
  end
217
229
  end
218
230
  end