tty-prompt 0.16.1 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/tty/prompt/messages.rb +49 -0
  4. data/lib/tty/prompt/version.rb +1 -3
  5. data/spec/spec_helper.rb +45 -0
  6. data/spec/unit/ask_spec.rb +132 -0
  7. data/spec/unit/choice/eql_spec.rb +22 -0
  8. data/spec/unit/choice/from_spec.rb +96 -0
  9. data/spec/unit/choices/add_spec.rb +12 -0
  10. data/spec/unit/choices/each_spec.rb +13 -0
  11. data/spec/unit/choices/find_by_spec.rb +10 -0
  12. data/spec/unit/choices/new_spec.rb +10 -0
  13. data/spec/unit/choices/pluck_spec.rb +9 -0
  14. data/spec/unit/collect_spec.rb +96 -0
  15. data/spec/unit/converters/convert_bool_spec.rb +58 -0
  16. data/spec/unit/converters/convert_char_spec.rb +11 -0
  17. data/spec/unit/converters/convert_custom_spec.rb +14 -0
  18. data/spec/unit/converters/convert_date_spec.rb +34 -0
  19. data/spec/unit/converters/convert_file_spec.rb +18 -0
  20. data/spec/unit/converters/convert_number_spec.rb +39 -0
  21. data/spec/unit/converters/convert_path_spec.rb +15 -0
  22. data/spec/unit/converters/convert_range_spec.rb +22 -0
  23. data/spec/unit/converters/convert_regex_spec.rb +12 -0
  24. data/spec/unit/converters/convert_string_spec.rb +21 -0
  25. data/spec/unit/converters/on_error_spec.rb +9 -0
  26. data/spec/unit/distance/distance_spec.rb +73 -0
  27. data/spec/unit/enum_paginator_spec.rb +75 -0
  28. data/spec/unit/enum_select_spec.rb +446 -0
  29. data/spec/unit/error_spec.rb +20 -0
  30. data/spec/unit/evaluator_spec.rb +67 -0
  31. data/spec/unit/expand_spec.rb +198 -0
  32. data/spec/unit/keypress_spec.rb +72 -0
  33. data/spec/unit/mask_spec.rb +132 -0
  34. data/spec/unit/multi_select_spec.rb +495 -0
  35. data/spec/unit/multiline_spec.rb +77 -0
  36. data/spec/unit/new_spec.rb +20 -0
  37. data/spec/unit/ok_spec.rb +10 -0
  38. data/spec/unit/paginator_spec.rb +73 -0
  39. data/spec/unit/question/checks_spec.rb +97 -0
  40. data/spec/unit/question/default_spec.rb +31 -0
  41. data/spec/unit/question/echo_spec.rb +38 -0
  42. data/spec/unit/question/in_spec.rb +115 -0
  43. data/spec/unit/question/initialize_spec.rb +12 -0
  44. data/spec/unit/question/modifier/apply_to_spec.rb +24 -0
  45. data/spec/unit/question/modifier/letter_case_spec.rb +41 -0
  46. data/spec/unit/question/modifier/whitespace_spec.rb +51 -0
  47. data/spec/unit/question/modify_spec.rb +41 -0
  48. data/spec/unit/question/required_spec.rb +92 -0
  49. data/spec/unit/question/validate_spec.rb +115 -0
  50. data/spec/unit/question/validation/call_spec.rb +31 -0
  51. data/spec/unit/question/validation/coerce_spec.rb +30 -0
  52. data/spec/unit/result_spec.rb +40 -0
  53. data/spec/unit/say_spec.rb +67 -0
  54. data/spec/unit/select_spec.rb +624 -0
  55. data/spec/unit/slider_spec.rb +100 -0
  56. data/spec/unit/statement/initialize_spec.rb +15 -0
  57. data/spec/unit/subscribe_spec.rb +20 -0
  58. data/spec/unit/suggest_spec.rb +28 -0
  59. data/spec/unit/warn_spec.rb +21 -0
  60. data/spec/unit/yes_no_spec.rb +235 -0
  61. data/tty-prompt.gemspec +4 -6
  62. metadata +120 -15
  63. data/.gitignore +0 -16
  64. data/.rspec +0 -3
  65. data/.travis.yml +0 -27
  66. data/CHANGELOG.md +0 -289
  67. data/CODE_OF_CONDUCT.md +0 -49
  68. data/Gemfile +0 -21
  69. data/appveyor.yml +0 -22
  70. data/benchmarks/speed.rb +0 -27
@@ -0,0 +1,446 @@
1
+ # encoding: utf-8
2
+
3
+ RSpec.describe TTY::Prompt do
4
+ let(:symbols) { TTY::Prompt::Symbols.symbols }
5
+
6
+ def output_helper(prompt, choices, active, options = {})
7
+ enum = options.fetch(:enum, ')')
8
+ input = options[:input]
9
+ error = options[:error]
10
+ default = options.fetch(:default, 1)
11
+
12
+ out = ""
13
+ out << prompt << " \n"
14
+ out << choices.map.with_index do |c, i|
15
+ name = c.is_a?(Hash) ? c[:name] : c
16
+ disabled = c.is_a?(Hash) ? c[:disabled] : false
17
+ num = (i + 1).to_s + enum
18
+ if disabled
19
+ "\e[31m#{symbols[:cross]}\e[0m #{num} #{name} #{disabled}"
20
+ elsif name == active
21
+ " \e[32m#{num} #{name}\e[0m"
22
+ else
23
+ " #{num} #{name}"
24
+ end
25
+ end.join("\n")
26
+ out << "\n"
27
+ choice = " Choose 1-#{choices.count} [#{default}]: "
28
+ choice << input.to_s if input
29
+ out << choice
30
+ if error
31
+ out << "\n"
32
+ out << "\e[31m>>\e[0m #{error}"
33
+ out << "\e[A\e[1G\e[#{choice.size}C"
34
+ end
35
+ out << "\e[2K\e[1G\e[1A" * (choices.count + 1)
36
+ out << "\e[2K\e[1G\e[J"
37
+ out
38
+ end
39
+
40
+ def exit_message(prompt, choice)
41
+ "#{prompt} \e[32m#{choice}\e[0m\n"
42
+ end
43
+
44
+ it "raises configuration error when wrong default" do
45
+ prompt = TTY::TestPrompt.new
46
+ choices = %w(/bin/nano /usr/bin/vim.basic /usr/bin/vim.tiny)
47
+
48
+ expect {
49
+ prompt.enum_select("Select an editor?", choices, default: 100)
50
+ }.to raise_error(TTY::Prompt::ConfigurationError,
51
+ /default index 100 out of range \(1 - 3\)/)
52
+ end
53
+
54
+ it "selects default option when return pressed immediately" do
55
+ choices = %w(/bin/nano /usr/bin/vim.basic /usr/bin/vim.tiny)
56
+ prompt = TTY::TestPrompt.new
57
+ prompt.input << "\n"
58
+ prompt.input.rewind
59
+
60
+ answer = prompt.enum_select("Select an editor?", choices)
61
+ expect(answer).to eq('/bin/nano')
62
+
63
+ expected_output =
64
+ output_helper("Select an editor?", choices, "/bin/nano") +
65
+ exit_message("Select an editor?", "/bin/nano")
66
+
67
+ expect(prompt.output.string).to eq(expected_output)
68
+ end
69
+
70
+ it "selects option by index from the list" do
71
+ choices = %w(/bin/nano /usr/bin/vim.basic /usr/bin/vim.tiny)
72
+ prompt = TTY::TestPrompt.new
73
+ prompt.input << "3\n"
74
+ prompt.input.rewind
75
+
76
+ answer = prompt.enum_select("Select an editor?", choices, default: 2)
77
+ expect(answer).to eq('/usr/bin/vim.tiny')
78
+
79
+ expected_output =
80
+ output_helper("Select an editor?", choices, "/usr/bin/vim.basic", default: 2) +
81
+ output_helper("Select an editor?", choices, "/usr/bin/vim.tiny", default: 2, input: '3') +
82
+ exit_message("Select an editor?", "/usr/bin/vim.tiny")
83
+
84
+ expect(prompt.output.string).to eq(expected_output)
85
+ end
86
+
87
+ it "selects option through DSL" do
88
+ choices = %w(/bin/nano /usr/bin/vim.basic /usr/bin/vim.tiny)
89
+ prompt = TTY::TestPrompt.new
90
+ prompt.input << "1\n"
91
+ prompt.input.rewind
92
+ answer = prompt.enum_select("Select an editor?") do |menu|
93
+ menu.default 2
94
+ menu.enum '.'
95
+
96
+ menu.choice "/bin/nano"
97
+ menu.choice "/usr/bin/vim.basic"
98
+ menu.choice "/usr/bin/vim.tiny"
99
+ end
100
+ expect(answer).to eq('/bin/nano')
101
+
102
+ expected_output =
103
+ output_helper("Select an editor?", choices, "/usr/bin/vim.basic", default: 2, enum: '.') +
104
+ output_helper("Select an editor?", choices, "/bin/nano", default: 2, enum: '.', input: 1) +
105
+ exit_message("Select an editor?", "/bin/nano")
106
+
107
+ expect(prompt.output.string).to eq(expected_output)
108
+ end
109
+
110
+ it "selects option through DSL with key and value" do
111
+ choices = %w(nano vim emacs)
112
+ prompt = TTY::TestPrompt.new
113
+ prompt.input << "\n"
114
+ prompt.input.rewind
115
+
116
+ answer = prompt.enum_select("Select an editor?") do |menu|
117
+ menu.default 2
118
+
119
+ menu.choice :nano, '/bin/nano'
120
+ menu.choice :vim, '/usr/bin/vim'
121
+ menu.choice :emacs, '/usr/bin/emacs'
122
+ end
123
+
124
+ expect(answer).to eq('/usr/bin/vim')
125
+
126
+ expected_output =
127
+ output_helper("Select an editor?", choices, "vim", default: 2) +
128
+ exit_message("Select an editor?", "vim")
129
+
130
+ expect(prompt.output.string).to eq(expected_output)
131
+ end
132
+
133
+ it "changes colors for selection, hint and error" do
134
+ prompt = TTY::TestPrompt.new
135
+ choices = %w(/bin/nano /usr/bin/vim.basic /usr/bin/vim.tiny)
136
+ prompt.input << "\n"
137
+ prompt.input.rewind
138
+ options = {active_color: :red, help_color: :blue, error_color: :green}
139
+ expect(prompt.enum_select("Select an editor?", choices, options)).to eq('/bin/nano')
140
+ expect(prompt.output.string).to eq([
141
+ "Select an editor? \n",
142
+ " \e[31m1) /bin/nano\e[0m\n",
143
+ " 2) /usr/bin/vim.basic\n",
144
+ " 3) /usr/bin/vim.tiny\n",
145
+ " Choose 1-3 [1]: ",
146
+ "\e[2K\e[1G\e[1A" * 4,
147
+ "\e[2K\e[1G\e[J",
148
+ "Select an editor? \e[31m/bin/nano\e[0m\n"
149
+ ].join)
150
+ end
151
+
152
+ it "displays error with unrecognized input" do
153
+ choices = %w(/bin/nano /usr/bin/vim.basic /usr/bin/vim.tiny)
154
+ prompt = TTY::TestPrompt.new
155
+ prompt.input << "11\n2\n"
156
+ prompt.input.rewind
157
+
158
+ answer = prompt.enum_select("Select an editor?", choices)
159
+ expect(answer).to eq('/usr/bin/vim.basic')
160
+
161
+ expected_output =
162
+ output_helper("Select an editor?", choices, "/bin/nano") +
163
+ output_helper("Select an editor?", choices, "/bin/nano", input: '1') +
164
+ output_helper("Select an editor?", choices, "/bin/nano", input: '11') +
165
+ output_helper("Select an editor?", choices, "/bin/nano", error: 'Please enter a valid number', input: '') +
166
+ output_helper("Select an editor?", choices, "/usr/bin/vim.basic", error: 'Please enter a valid number', input: '2') +
167
+ exit_message("Select an editor?", "/usr/bin/vim.basic")
168
+
169
+ expect(prompt.output.string).to eq(expected_output)
170
+ end
171
+
172
+ it "paginates long selections" do
173
+ choices = %w(A B C D E F G H)
174
+ prompt = TTY::TestPrompt.new
175
+ prompt.input << "\n"
176
+ prompt.input.rewind
177
+
178
+ answer = prompt.enum_select("What letter?", choices, per_page: 3, default: 4)
179
+ expect(answer).to eq('D')
180
+
181
+ expect(prompt.output.string).to eq([
182
+ "What letter? \n",
183
+ " \e[32m4) D\e[0m\n",
184
+ " 5) E\n",
185
+ " 6) F\n",
186
+ " Choose 1-8 [4]: ",
187
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
188
+ "\e[A\e[1G\e[18C",
189
+ "\e[2K\e[1G\e[1A" * 4,
190
+ "\e[2K\e[1G\e[J",
191
+ "What letter? \e[32mD\e[0m\n"
192
+ ].join)
193
+ end
194
+
195
+ it "doesn't paginate short selections" do
196
+ choices = %w(A B C D)
197
+ prompt = TTY::TestPrompt.new
198
+ prompt.input << "\r"
199
+ prompt.input.rewind
200
+
201
+ answer = prompt.enum_select("What letter?", choices, per_page: 4, default: 1)
202
+ expect(answer).to eq('A')
203
+
204
+ expected_output =
205
+ output_helper("What letter?", choices, "A") +
206
+ exit_message("What letter?", "A")
207
+
208
+ expect(prompt.output.string).to eq(expected_output)
209
+ end
210
+
211
+ it "shows pages matching input" do
212
+ prompt = TTY::TestPrompt.new
213
+ choices = %w(A B C D E F G H)
214
+ prompt.input << "11\n\b\n"
215
+ prompt.input.rewind
216
+ value = prompt.enum_select("What letter?", choices, per_page: 3)
217
+ expect(value).to eq('A')
218
+ expect(prompt.output.string).to eq([
219
+ "What letter? \n",
220
+ " \e[32m1) A\e[0m\n",
221
+ " 2) B\n",
222
+ " 3) C\n",
223
+ " Choose 1-8 [1]: ",
224
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
225
+ "\e[A\e[1G\e[18C",
226
+ "\e[2K\e[1G\e[1A" * 4,
227
+ "\e[2K\e[1G\e[J",
228
+ "What letter? \n",
229
+ " \e[32m1) A\e[0m\n",
230
+ " 2) B\n",
231
+ " 3) C\n",
232
+ " Choose 1-8 [1]: 1",
233
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
234
+ "\e[A\e[1G\e[19C",
235
+ "\e[2K\e[1G\e[1A" * 4,
236
+ "\e[2K\e[1G\e[J",
237
+ "What letter? \n",
238
+ " \e[32m1) A\e[0m\n",
239
+ " 2) B\n",
240
+ " 3) C\n",
241
+ " Choose 1-8 [1]: 11",
242
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
243
+ "\e[A\e[1G\e[20C",
244
+ "\e[2K\e[1G\e[1A" * 4,
245
+ "\e[2K\e[1G\e[J",
246
+ "What letter? \n",
247
+ " \e[32m1) A\e[0m\n",
248
+ " 2) B\n",
249
+ " 3) C\n",
250
+ " Choose 1-8 [1]: \n",
251
+ "\e[31m>>\e[0m Please enter a valid number",
252
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
253
+ "\e[A\e[1G\e[A\e[1G\e[18C",
254
+ "\e[2K\e[1G\e[1A" * 4,
255
+ "\e[2K\e[1G\e[J",
256
+ "What letter? \n",
257
+ " \e[32m1) A\e[0m\n",
258
+ " 2) B\n",
259
+ " 3) C\n",
260
+ " Choose 1-8 [1]: \n",
261
+ "\e[31m>>\e[0m Please enter a valid number",
262
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
263
+ "\e[A\e[1G\e[A\e[1G\e[18C",
264
+ "\e[2K\e[1G\e[1A" * 4,
265
+ "\e[2K\e[1G\e[J",
266
+ "What letter? \e[32mA\e[0m\n"
267
+ ].join)
268
+ end
269
+
270
+ it "switches through pages with tab key" do
271
+ prompt = TTY::TestPrompt.new
272
+ choices = %w(A B C D E F G H)
273
+ prompt.input << "\t\n"
274
+ prompt.input.rewind
275
+ value = prompt.enum_select("What letter?") do |menu|
276
+ menu.default 4
277
+ menu.per_page 3
278
+ menu.choices choices
279
+ end
280
+ expect(value).to eq('D')
281
+ expect(prompt.output.string).to eq([
282
+ "What letter? \n",
283
+ " \e[32m4) D\e[0m\n",
284
+ " 5) E\n",
285
+ " 6) F\n",
286
+ " Choose 1-8 [4]: ",
287
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
288
+ "\e[A\e[1G\e[18C",
289
+ "\e[2K\e[1G\e[1A" * 4,
290
+ "\e[2K\e[1G\e[J",
291
+ "What letter? \n",
292
+ " 7) G\n",
293
+ " 8) H\n",
294
+ " Choose 1-8 [4]: ",
295
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
296
+ "\e[A\e[1G\e[18C",
297
+ "\e[2K\e[1G\e[1A" * 3,
298
+ "\e[2K\e[1G\e[J",
299
+ "What letter? \e[32mD\e[0m\n"
300
+ ].join)
301
+ end
302
+
303
+ it "doesn't cycle around by default" do
304
+ prompt = TTY::TestPrompt.new
305
+ choices = %w(A B C D E F)
306
+ prompt.input << "\t" << "\t" << "\n"
307
+ prompt.input.rewind
308
+ value = prompt.enum_select("What letter?") do |menu|
309
+ menu.default 1
310
+ menu.per_page 3
311
+ menu.choices choices
312
+ end
313
+ expect(value).to eq("A")
314
+ expect(prompt.output.string).to eq([
315
+ "What letter? \n",
316
+ " \e[32m1) A\e[0m\n",
317
+ " 2) B\n",
318
+ " 3) C\n",
319
+ " Choose 1-6 [1]: ",
320
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
321
+ "\e[A\e[1G\e[18C",
322
+ "\e[2K\e[1G\e[1A" * 4,
323
+ "\e[2K\e[1G\e[J",
324
+ "What letter? \n",
325
+ " 4) D\n",
326
+ " 5) E\n",
327
+ " 6) F\n",
328
+ " Choose 1-6 [1]: ",
329
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
330
+ "\e[A\e[1G\e[18C",
331
+ "\e[2K\e[1G\e[1A" * 4,
332
+ "\e[2K\e[1G\e[J",
333
+ "What letter? \n",
334
+ " 4) D\n",
335
+ " 5) E\n",
336
+ " 6) F\n",
337
+ " Choose 1-6 [1]: ",
338
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
339
+ "\e[A\e[1G\e[18C",
340
+ "\e[2K\e[1G\e[1A" * 4,
341
+ "\e[2K\e[1G\e[J",
342
+ "What letter? \e[32mA\e[0m\n"
343
+ ].join)
344
+ end
345
+
346
+ it "cycles around when configured to do so" do
347
+ prompt = TTY::TestPrompt.new
348
+ choices = %w(A B C D E F)
349
+ prompt.input << "\t" << "\t" << "\n"
350
+ prompt.input.rewind
351
+ value = prompt.enum_select("What letter?", cycle: true) do |menu|
352
+ menu.default 1
353
+ menu.per_page 3
354
+ menu.choices choices
355
+ end
356
+ expect(value).to eq("A")
357
+ expect(prompt.output.string).to eq([
358
+ "What letter? \n",
359
+ " \e[32m1) A\e[0m\n",
360
+ " 2) B\n",
361
+ " 3) C\n",
362
+ " Choose 1-6 [1]: ",
363
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
364
+ "\e[A\e[1G\e[18C",
365
+ "\e[2K\e[1G\e[1A" * 4,
366
+ "\e[2K\e[1G\e[J",
367
+ "What letter? \n",
368
+ " 4) D\n",
369
+ " 5) E\n",
370
+ " 6) F\n",
371
+ " Choose 1-6 [1]: ",
372
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
373
+ "\e[A\e[1G\e[18C",
374
+ "\e[2K\e[1G\e[1A" * 4,
375
+ "\e[2K\e[1G\e[J",
376
+ "What letter? \n",
377
+ " \e[32m1) A\e[0m\n",
378
+ " 2) B\n",
379
+ " 3) C\n",
380
+ " Choose 1-6 [1]: ",
381
+ "\n\e[90m(Press tab/right or left to reveal more choices)\e[0m",
382
+ "\e[A\e[1G\e[18C",
383
+ "\e[2K\e[1G\e[1A" * 4,
384
+ "\e[2K\e[1G\e[J",
385
+ "What letter? \e[32mA\e[0m\n"
386
+ ].join)
387
+ end
388
+
389
+ context "with :disabled choice" do
390
+ it "fails when active item is also disabled" do
391
+ prompt = TTY::TestPrompt.new
392
+ choices = [{name: 'A', disabled: true}, 'B', 'C', 'D', 'E']
393
+ expect {
394
+ prompt.enum_select("What letter?", choices)
395
+ }.to raise_error(TTY::Prompt::ConfigurationError,
396
+ /default index 1 matches disabled choice item/)
397
+ end
398
+
399
+ it "doesn't allow to choose disabled choice and defaults" do
400
+ choices = ['A', {name: 'B', disabled: '(out)'}, 'C', 'D', 'E', 'F']
401
+ prompt = TTY::TestPrompt.new
402
+ prompt.input << "2" << "\n" << "3" << "\n"
403
+ prompt.input.rewind
404
+
405
+ answer = prompt.enum_select("What letter?", choices)
406
+ expect(answer).to eq("C")
407
+
408
+ expected_output =
409
+ output_helper("What letter?", choices, 'A') +
410
+ output_helper("What letter?", choices, 'A', input: '2') +
411
+ output_helper("What letter?", choices, 'A', input: '', error: 'Please enter a valid number') +
412
+ output_helper("What letter?", choices, 'C', input: '3', error: 'Please enter a valid number') +
413
+ exit_message("What letter?", "C")
414
+
415
+ expect(prompt.output.string).to eq(expected_output)
416
+ end
417
+
418
+ it "omits disabled choice when navigating with numbers" do
419
+ choices = [
420
+ {name: 'A'},
421
+ {name: 'B', disabled: '(out)'},
422
+ {name: 'C', disabled: '(out)'},
423
+ {name: 'D'},
424
+ {name: 'E'}
425
+ ]
426
+ prompt = TTY::TestPrompt.new
427
+ prompt.on(:keypress) { |e| prompt.trigger(:keydelete) if e.value == "B"}
428
+ prompt.input << "2" << "\u007F" << "3" << "\u007F" << '4' << "\n"
429
+ prompt.input.rewind
430
+
431
+ answer = prompt.enum_select("What letter?", choices)
432
+ expect(answer).to eq("D")
433
+
434
+ expected_output =
435
+ output_helper("What letter?", choices, 'A') +
436
+ output_helper("What letter?", choices, 'A', input: '2') +
437
+ output_helper("What letter?", choices, 'A', input: '') +
438
+ output_helper("What letter?", choices, 'A', input: '3') +
439
+ output_helper("What letter?", choices, 'A', input: '') +
440
+ output_helper("What letter?", choices, 'D', input: '4') +
441
+ exit_message("What letter?", "D")
442
+
443
+ expect(prompt.output.string).to eq(expected_output)
444
+ end
445
+ end
446
+ end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ RSpec.describe TTY::Prompt, '.error' do
4
+ subject(:prompt) { TTY::TestPrompt.new }
5
+
6
+ it 'displays one message' do
7
+ prompt.error "Nothing is fine!"
8
+ expect(prompt.output.string).to eql "\e[31mNothing is fine!\e[0m\n"
9
+ end
10
+
11
+ it 'displays many messages' do
12
+ prompt.error "Nothing is fine!", "All is broken!"
13
+ expect(prompt.output.string).to eql "\e[31mNothing is fine!\e[0m\n\e[31mAll is broken!\e[0m\n"
14
+ end
15
+
16
+ it 'displays message with option' do
17
+ prompt.error "Nothing is fine!", newline: false
18
+ expect(prompt.output.string).to eql "\e[31mNothing is fine!\e[0m"
19
+ end
20
+ end