highline 1.7.10 → 2.0.0.pre.develop.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.simplecov +5 -0
  4. data/.travis.yml +11 -6
  5. data/Changelog.md +112 -20
  6. data/Gemfile +8 -7
  7. data/README.rdoc +3 -0
  8. data/Rakefile +7 -2
  9. data/appveyor.yml +19 -0
  10. data/examples/asking_for_arrays.rb +3 -0
  11. data/examples/basic_usage.rb +3 -0
  12. data/examples/get_character.rb +3 -0
  13. data/examples/limit.rb +3 -0
  14. data/examples/menus.rb +3 -0
  15. data/examples/overwrite.rb +3 -0
  16. data/examples/password.rb +3 -0
  17. data/examples/repeat_entry.rb +4 -1
  18. data/lib/highline.rb +182 -704
  19. data/lib/highline/builtin_styles.rb +109 -0
  20. data/lib/highline/color_scheme.rb +4 -1
  21. data/lib/highline/compatibility.rb +2 -0
  22. data/lib/highline/custom_errors.rb +19 -0
  23. data/lib/highline/import.rb +4 -2
  24. data/lib/highline/list.rb +93 -0
  25. data/lib/highline/list_renderer.rb +232 -0
  26. data/lib/highline/menu.rb +20 -20
  27. data/lib/highline/paginator.rb +43 -0
  28. data/lib/highline/question.rb +157 -97
  29. data/lib/highline/question/answer_converter.rb +84 -0
  30. data/lib/highline/question_asker.rb +147 -0
  31. data/lib/highline/simulate.rb +5 -1
  32. data/lib/highline/statement.rb +58 -0
  33. data/lib/highline/string.rb +34 -0
  34. data/lib/highline/string_extensions.rb +3 -28
  35. data/lib/highline/style.rb +18 -8
  36. data/lib/highline/template_renderer.rb +38 -0
  37. data/lib/highline/terminal.rb +78 -0
  38. data/lib/highline/terminal/io_console.rb +98 -0
  39. data/lib/highline/terminal/ncurses.rb +38 -0
  40. data/lib/highline/terminal/unix_stty.rb +94 -0
  41. data/lib/highline/version.rb +3 -1
  42. data/lib/highline/wrapper.rb +43 -0
  43. data/test/acceptance/acceptance.rb +62 -0
  44. data/test/acceptance/acceptance_test.rb +69 -0
  45. data/test/acceptance/at_color_output_using_erb_templates.rb +17 -0
  46. data/test/acceptance/at_echo_false.rb +23 -0
  47. data/test/acceptance/at_readline.rb +37 -0
  48. data/test/io_console_compatible.rb +37 -0
  49. data/test/string_methods.rb +3 -0
  50. data/test/test_answer_converter.rb +26 -0
  51. data/test/{tc_color_scheme.rb → test_color_scheme.rb} +7 -9
  52. data/test/test_helper.rb +26 -0
  53. data/test/{tc_highline.rb → test_highline.rb} +193 -136
  54. data/test/{tc_import.rb → test_import.rb} +5 -2
  55. data/test/test_list.rb +60 -0
  56. data/test/{tc_menu.rb → test_menu.rb} +6 -3
  57. data/test/test_paginator.rb +73 -0
  58. data/test/test_question_asker.rb +20 -0
  59. data/test/test_simulator.rb +24 -0
  60. data/test/test_string_extension.rb +72 -0
  61. data/test/{tc_string_highline.rb → test_string_highline.rb} +7 -3
  62. data/test/{tc_style.rb → test_style.rb} +70 -35
  63. data/test/test_wrapper.rb +188 -0
  64. metadata +57 -22
  65. data/lib/highline/system_extensions.rb +0 -254
  66. data/test/tc_simulator.rb +0 -33
  67. data/test/tc_string_extension.rb +0 -33
@@ -1,3 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
1
4
  # tc_import.rb
2
5
  #
3
6
  # Created by James Edward Gray II on 2005-04-26.
@@ -5,12 +8,12 @@
5
8
  #
6
9
  # This is Free Software. See LICENSE and COPYING for details.
7
10
 
8
- require "test/unit"
11
+ require "test_helper"
9
12
 
10
13
  require "highline/import"
11
14
  require "stringio"
12
15
 
13
- class TestImport < Test::Unit::TestCase
16
+ class TestImport < Minitest::Test
14
17
  def test_import
15
18
  assert_respond_to(self, :agree)
16
19
  assert_respond_to(self, :ask)
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "test_helper"
5
+
6
+ require "highline/list"
7
+
8
+ class TestHighLineList < Minitest::Test
9
+ def setup
10
+ @items = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" ]
11
+ end
12
+
13
+ def test_in_2_cols
14
+ list_in_two_cols =
15
+ [ [ "a", "b" ],
16
+ [ "c", "d" ],
17
+ [ "e", "f" ],
18
+ [ "g", "h" ],
19
+ [ "i", "j" ] ]
20
+
21
+ highline_list = HighLine::List.new(@items, cols: 2)
22
+
23
+ assert_equal list_in_two_cols, highline_list.list
24
+ end
25
+
26
+ def test_in_2_cols_col_down
27
+ col_down_list =
28
+ [ [ "a", "f"],
29
+ [ "b", "g"],
30
+ [ "c", "h"],
31
+ [ "d", "i"],
32
+ [ "e", "j"] ]
33
+
34
+ highline_list = HighLine::List.new(@items, cols: 2, col_down: true)
35
+
36
+ assert_equal col_down_list, highline_list.list
37
+ end
38
+
39
+ def test_in_2_cols_transposed
40
+ transposed_list =
41
+ [ [ "a", "c", "e", "g", "i" ],
42
+ [ "b", "d", "f", "h", "j" ] ]
43
+
44
+ highline_list = HighLine::List.new(@items, cols: 2, transpose: true)
45
+
46
+ assert_equal transposed_list, highline_list.list
47
+ end
48
+
49
+ def test_in_3_cols
50
+ list_in_three_cols =
51
+ [ [ "a", "b", "c" ],
52
+ [ "d", "e", "f" ],
53
+ [ "g", "h", "i" ],
54
+ [ "j" ] ]
55
+
56
+ highline_list = HighLine::List.new(@items, cols: 3)
57
+
58
+ assert_equal list_in_three_cols, highline_list.list
59
+ end
60
+ end
@@ -1,4 +1,6 @@
1
+ #!/usr/bin/env ruby
1
2
  # coding: utf-8
3
+
2
4
  # tc_menu.rb
3
5
  #
4
6
  # Created by Gregory Thomas Brown on 2005-05-10.
@@ -6,13 +8,14 @@
6
8
  #
7
9
  # This is Free Software. See LICENSE and COPYING for details.
8
10
 
9
- require "test/unit"
11
+ require "test_helper"
10
12
 
11
13
  require "highline"
12
14
  require "stringio"
13
15
 
14
- class TestMenu < Test::Unit::TestCase
16
+ class TestMenu < Minitest::Test
15
17
  def setup
18
+ HighLine.reset
16
19
  @input = StringIO.new
17
20
  @output = StringIO.new
18
21
  @terminal = HighLine.new(@input, @output)
@@ -201,7 +204,7 @@ class TestMenu < Test::Unit::TestCase
201
204
  @output.truncate(@output.rewind)
202
205
 
203
206
  @terminal.choose(:load, :save, :quit) do |menu|
204
- menu.layout = '<%= list(@menu) %>File Menu: '
207
+ menu.layout = '<%= list(menu) %>File Menu: '
205
208
  end
206
209
  assert_equal("1. load\n2. save\n3. quit\nFile Menu: ", @output.string)
207
210
  end
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "test_helper"
5
+
6
+ require "highline"
7
+
8
+ class TestHighLinePaginator < Minitest::Test
9
+ def setup
10
+ HighLine.reset
11
+ @input = StringIO.new
12
+ @output = StringIO.new
13
+ @terminal = HighLine.new(@input, @output)
14
+ end
15
+
16
+ def test_paging
17
+ @terminal.page_at = 22
18
+
19
+ @input << "\n\n"
20
+ @input.rewind
21
+
22
+ @terminal.say((1..50).map { |n| "This is line #{n}.\n"}.join)
23
+ assert_equal( (1..22).map { |n| "This is line #{n}.\n"}.join +
24
+ "\n-- press enter/return to continue or q to stop -- \n\n" +
25
+ (23..44).map { |n| "This is line #{n}.\n"}.join +
26
+ "\n-- press enter/return to continue or q to stop -- \n\n" +
27
+ (45..50).map { |n| "This is line #{n}.\n"}.join,
28
+ @output.string )
29
+ end
30
+
31
+ def test_statement_lines_count_equal_to_page_at_shouldnt_paginate
32
+ @terminal.page_at = 6
33
+
34
+ @input << "\n"
35
+ @input.rewind
36
+
37
+ list = "a\nb\nc\nd\ne\nf\n"
38
+
39
+ @terminal.say(list)
40
+ assert_equal(list, @output.string)
41
+ end
42
+
43
+ def test_statement_with_one_line_bigger_than_page_at_should_paginate
44
+ @terminal.page_at = 6
45
+
46
+ @input << "\n"
47
+ @input.rewind
48
+
49
+ list = "a\nb\nc\nd\ne\nf\ng\n"
50
+
51
+ paginated =
52
+ "a\nb\nc\nd\ne\nf\n" \
53
+ "\n-- press enter/return to continue or q to stop -- \n\n" \
54
+ "g\n"
55
+
56
+ @terminal.say(list)
57
+ assert_equal(paginated, @output.string)
58
+ end
59
+
60
+ def test_quiting_paging_shouldnt_raise
61
+ # See https://github.com/JEG2/highline/issues/168
62
+
63
+ @terminal.page_at = 6
64
+
65
+ @input << "q"
66
+ @input.rewind
67
+
68
+ list = "a\nb\nc\nd\ne\nf\n"
69
+
70
+ # expect not to raise an error on next line
71
+ @terminal.say(list)
72
+ end
73
+ end
@@ -0,0 +1,20 @@
1
+ require "test_helper"
2
+
3
+ class TestQuestion < Minitest::Test
4
+ def setup
5
+ @input = StringIO.new
6
+ @output = StringIO.new
7
+ @highline = HighLine.new(@input, @output)
8
+
9
+ @question = HighLine::Question.new("How are you?", nil)
10
+ @asker = HighLine::QuestionAsker.new(@question, @highline)
11
+ end
12
+
13
+ def test_ask_once
14
+ answer = "Very good, thanks for asking!"
15
+
16
+ @input.string = answer
17
+
18
+ assert_equal answer, @asker.ask_once
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ require "test_helper"
2
+
3
+ require "highline/import"
4
+ require "highline/simulate"
5
+
6
+ class SimulatorTest < Minitest::Test
7
+ def setup
8
+ input = StringIO.new
9
+ output = StringIO.new
10
+ $terminal = HighLine.new(input, output)
11
+ end
12
+
13
+ def test_simulator
14
+ HighLine::Simulate.with("Bugs Bunny", "18") do
15
+ name = ask("What is your name?")
16
+
17
+ assert_equal "Bugs Bunny", name
18
+
19
+ age = ask("What is your age?")
20
+
21
+ assert_equal "18", age
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ # tc_string_extension.rb
5
+ #
6
+ # Created by Richard LeBer 2011-06-27
7
+ #
8
+ # This is Free Software. See LICENSE and COPYING for details.
9
+
10
+ require "test_helper"
11
+
12
+ require "highline"
13
+ require "stringio"
14
+ require "string_methods"
15
+
16
+
17
+ # FakeString is here just to avoid
18
+ # using HighLine.colorize_strings
19
+ # on tests
20
+
21
+ class FakeString < String
22
+ include HighLine::StringExtensions
23
+ end
24
+
25
+ class TestStringExtension < Minitest::Test
26
+ def setup
27
+ HighLine.reset
28
+ @string = FakeString.new "string"
29
+ end
30
+
31
+ def teardown
32
+ HighLine.reset
33
+ end
34
+
35
+ include StringMethods
36
+
37
+ def test_Highline_String_is_yaml_serializable
38
+ require 'yaml'
39
+ unless Gem::Version.new(YAML::VERSION) < Gem::Version.new("2.0.2")
40
+ highline_string = HighLine::String.new("Yaml didn't messed with HighLine::String")
41
+ yaml_highline_string = highline_string.to_yaml
42
+ yaml_loaded_string = YAML.load(yaml_highline_string)
43
+
44
+ assert_equal "Yaml didn't messed with HighLine::String", yaml_loaded_string
45
+ assert_equal highline_string, yaml_loaded_string
46
+ assert_instance_of HighLine::String, yaml_loaded_string
47
+ end
48
+ end
49
+
50
+ def test_highline_string_respond_to_color
51
+ assert HighLine::String.new("highline string").respond_to? :color
52
+ end
53
+
54
+ def test_normal_string_doesnt_respond_to_color
55
+ refute "normal_string".respond_to? :color
56
+ end
57
+
58
+ def test_highline_string_still_raises_for_non_available_messages
59
+ assert_raises(NoMethodError) do
60
+ @string.unknown_message
61
+ end
62
+ end
63
+
64
+ def test_String_includes_StringExtension_when_receives_colorize_strings
65
+ @include_received = 0
66
+ caller = Proc.new { @include_received += 1 }
67
+ ::String.stub :include, caller do
68
+ HighLine.colorize_strings
69
+ end
70
+ assert_equal 1, @include_received
71
+ end
72
+ end
@@ -1,17 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
1
4
  # tc_highline_string.rb
2
5
  #
3
6
  # Created by Richard LeBer 2011-06-27
4
7
  #
5
8
  # This is Free Software. See LICENSE and COPYING for details.
6
9
 
7
- require "test/unit"
10
+ require "test_helper"
8
11
 
9
12
  require "highline"
10
13
  require "stringio"
11
14
  require "string_methods"
12
15
 
13
- class TestHighLineString < Test::Unit::TestCase
16
+ class TestHighLineString < Minitest::Test
14
17
  def setup
18
+ HighLine.reset
15
19
  @string = HighLine::String.new("string")
16
20
  end
17
21
 
@@ -33,6 +37,6 @@ class TestHighLineString < Test::Unit::TestCase
33
37
  include StringMethods
34
38
 
35
39
  def test_string_class_is_unchanged
36
- assert_raise(::NoMethodError) { "string".color(:blue) }
40
+ assert_raises(::NoMethodError) { "string".color(:blue) }
37
41
  end
38
42
  end
@@ -1,17 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
1
4
  # tc_style.rb
2
5
  #
3
6
  # Created by Richard LeBer on 2011-06-11.
4
7
  #
5
8
  # This is Free Software. See LICENSE and COPYING for details.
6
9
 
7
- require "test/unit"
10
+ require "test_helper"
8
11
 
9
12
  require "highline"
10
13
  require "stringio"
11
14
 
12
- class TestStyle < Test::Unit::TestCase
15
+ class TestStyle < Minitest::Test
13
16
 
14
17
  def setup
18
+ HighLine.reset
15
19
  @input = StringIO.new
16
20
  @output = StringIO.new
17
21
  @terminal = HighLine.new(@input, @output)
@@ -19,12 +23,33 @@ class TestStyle < Test::Unit::TestCase
19
23
  @style2 = HighLine::Style.new(:name=>:lando, :code=>"\e[98m")
20
24
  @style3 = HighLine::Style.new(:name=>[:foo, :lando], :list=>[:foo, :lando])
21
25
  @style4 = HighLine::Style(:rgb_654321)
26
+ @added_styles_on_setup = 4 # update here if added more styles
27
+ @added_codes_to_index = 3 # :foo, :lando and :rgb_654321
22
28
  end
23
-
24
- def teardown
25
- # HighLine::Style.clear_index
29
+
30
+ def test_clear_index_reset_styles_to_builtin
31
+ styles_size_after_setup = HighLine::Style.list.size
32
+ expected_styles_size = styles_size_after_setup - @added_styles_on_setup
33
+
34
+ HighLine::Style.clear_index
35
+ styles_size_after_clear_index = HighLine::Style.list.size
36
+
37
+ assert_equal expected_styles_size, styles_size_after_clear_index
26
38
  end
27
-
39
+
40
+ def test_clear_index_reset_code_index_to_builtin
41
+ code_index = HighLine::Style.code_index
42
+ code_index_array = code_index.map { |code, style_array| style_array }.flatten
43
+ expected_code_index_array_size = code_index_array.size - @added_codes_to_index
44
+
45
+ HighLine::Style.clear_index
46
+
47
+ cleared_code_index = HighLine::Style.code_index
48
+ cleared_code_index_array = cleared_code_index.map { |code, style_array| style_array }.flatten
49
+
50
+ assert_equal expected_code_index_array_size, cleared_code_index_array.size
51
+ end
52
+
28
53
  def test_style_method
29
54
  # Retrieve a style from an existing Style (no new Style created)
30
55
  new_style = @style1.dup # This will replace @style1 in the indexes
@@ -44,18 +69,28 @@ class TestStyle < Test::Unit::TestCase
44
69
  assert_nil s.list
45
70
  assert_equal "\e[1m", s.code
46
71
  assert_equal :bold, s.name
72
+ assert s.builtin
47
73
 
48
74
  # Create a builtin style from a new ANSI escape string
49
75
  s = HighLine.Style("\e[96m")
50
76
  assert_instance_of HighLine::Style, s
51
77
  assert_nil s.list
52
78
  assert_equal "\e[96m", s.code
79
+ assert s.builtin
80
+
81
+ # Create a non-builtin style from a string
82
+ s = HighLine.Style("\e[109m")
83
+ assert_instance_of HighLine::Style, s
84
+ assert_nil s.list
85
+ assert_equal "\e[109m", s.code
86
+ refute s.builtin
53
87
 
54
88
  # Create a builtin style from a symbol
55
89
  s = HighLine.Style(:red)
56
90
  assert_instance_of HighLine::Style, s
57
91
  assert_nil s.list
58
92
  assert_equal :red, s.name
93
+ assert s.builtin
59
94
 
60
95
  # Retrieve an existing style by name (no new Style created)
61
96
  s = HighLine.Style(@style2.name)
@@ -101,12 +136,12 @@ class TestStyle < Test::Unit::TestCase
101
136
  assert_equal [:underline, :blue], s1.list
102
137
 
103
138
  # Raise an error for an undefined style
104
- assert_raise(::NameError) { HighLine.Style(:fubar) }
139
+ assert_raises(::NameError) { HighLine.Style(:fubar) }
105
140
  end
106
141
 
107
142
  def test_no_color_scheme
108
143
  HighLine.color_scheme = nil
109
- assert_raise(::NameError) { HighLine.Style(:critical) }
144
+ assert_raises(::NameError) { HighLine.Style(:critical) }
110
145
  end
111
146
 
112
147
  def test_with_color_scheme
@@ -155,7 +190,7 @@ class TestStyle < Test::Unit::TestCase
155
190
  assert_nil HighLine::Style.list[:s1]
156
191
  assert_nil HighLine::Style.code_index['foo']
157
192
  s1 = HighLine::Style.new(:name=>:s1, :code=>'foo')
158
- assert_not_nil HighLine::Style.list[:s1]
193
+ refute_nil HighLine::Style.list[:s1]
159
194
  assert_same s1, HighLine::Style.list[:s1]
160
195
  assert_equal :s1, HighLine::Style.list[:s1].name
161
196
  assert_equal 'foo', HighLine::Style.list[:s1].code
@@ -173,7 +208,7 @@ class TestStyle < Test::Unit::TestCase
173
208
  s2 = HighLine::Style.new(:name=>:s2, :code=>'bar')
174
209
  assert_equal styles+1, HighLine::Style.list.size
175
210
  assert_equal codes+1, HighLine::Style.code_index.size
176
- assert_not_nil HighLine::Style.list[:s2]
211
+ refute_nil HighLine::Style.list[:s2]
177
212
  assert_same s2, HighLine::Style.list[:s2]
178
213
  assert_equal :s2, HighLine::Style.list[:s2].name
179
214
  assert_equal 'bar', HighLine::Style.list[:s2].code
@@ -185,16 +220,16 @@ class TestStyle < Test::Unit::TestCase
185
220
 
186
221
  # Add a Style with an existing name
187
222
  s3_before = HighLine::Style.list[:s2]
188
- assert_not_nil HighLine::Style.list[:s2]
223
+ refute_nil HighLine::Style.list[:s2]
189
224
  assert_nil HighLine::Style.code_index['baz']
190
225
  s3 = HighLine::Style.new(:name=>:s2, :code=>'baz')
191
- assert_not_same s2, s3
192
- assert_not_same s3_before, s3
226
+ refute_same s2, s3
227
+ refute_same s3_before, s3
193
228
  assert_equal styles+1, HighLine::Style.list.size
194
229
  assert_equal codes+2, HighLine::Style.code_index.size
195
- assert_not_nil HighLine::Style.list[:s2]
230
+ refute_nil HighLine::Style.list[:s2]
196
231
  assert_same s3, HighLine::Style.list[:s2]
197
- assert_not_same s2, HighLine::Style.list[:s2]
232
+ refute_same s2, HighLine::Style.list[:s2]
198
233
  assert_equal :s2, HighLine::Style.list[:s2].name
199
234
  assert_equal 'baz', HighLine::Style.list[:s2].code
200
235
  assert_instance_of Array, HighLine::Style.code_index['baz']
@@ -208,7 +243,7 @@ class TestStyle < Test::Unit::TestCase
208
243
  s4 = HighLine::Style.new(:name=>:s4, :code=>'baz')
209
244
  assert_equal styles+2, HighLine::Style.list.size
210
245
  assert_equal codes+2, HighLine::Style.code_index.size
211
- assert_not_nil HighLine::Style.list[:s4]
246
+ refute_nil HighLine::Style.list[:s4]
212
247
  assert_same s4, HighLine::Style.list[:s4]
213
248
  assert_equal :s4, HighLine::Style.list[:s4].name
214
249
  assert_equal 'baz', HighLine::Style.list[:s4].code
@@ -348,9 +383,9 @@ class TestStyle < Test::Unit::TestCase
348
383
  # Add a Style with a new name and code
349
384
  assert_nil HighLine::Style.list[:s5]
350
385
  s5 = HighLine::Style.new(:name=>:s5, :code=>'foo')
351
- assert_not_nil HighLine::Style.list[:s5]
386
+ refute_nil HighLine::Style.list[:s5]
352
387
  assert_equal list_size+1, HighLine::Style.list.size
353
- assert_not_nil HighLine::Style.list[:s5]
388
+ refute_nil HighLine::Style.list[:s5]
354
389
  assert_same s5, HighLine::Style.list[:s5]
355
390
  assert_equal :s5, HighLine::Style.list[:s5].name
356
391
  assert_equal 'foo', HighLine::Style.list[:s5].code
@@ -359,7 +394,7 @@ class TestStyle < Test::Unit::TestCase
359
394
  assert_nil HighLine::Style.list[:s6]
360
395
  s6 = HighLine::Style.new(:name=>:s6, :code=>'bar')
361
396
  assert_equal list_size+2, HighLine::Style.list.size
362
- assert_not_nil HighLine::Style.list[:s6]
397
+ refute_nil HighLine::Style.list[:s6]
363
398
  assert_same s6, HighLine::Style.list[:s6]
364
399
  assert_equal :s6, HighLine::Style.list[:s6].name
365
400
  assert_equal 'bar', HighLine::Style.list[:s6].code
@@ -367,9 +402,9 @@ class TestStyle < Test::Unit::TestCase
367
402
  # Add a Style with an existing name
368
403
  s7 = HighLine::Style.new(:name=>:s6, :code=>'baz')
369
404
  assert_equal list_size+2, HighLine::Style.list.size # No net addition to list
370
- assert_not_nil HighLine::Style.list[:s6]
405
+ refute_nil HighLine::Style.list[:s6]
371
406
  assert_same s7, HighLine::Style.list[:s6] # New one replaces old one
372
- assert_not_same s6, HighLine::Style.list[:s6]
407
+ refute_same s6, HighLine::Style.list[:s6]
373
408
  assert_equal :s6, HighLine::Style.list[:s6].name
374
409
  assert_equal 'baz', HighLine::Style.list[:s6].code
375
410
  end
@@ -460,35 +495,35 @@ class TestStyle < Test::Unit::TestCase
460
495
 
461
496
  s1 = @style1.variant(:new_foo1, :code=>'abracadabra')
462
497
  assert_instance_of HighLine::Style, s1
463
- assert_not_same @style1, s1 # This is a copy
498
+ refute_same @style1, s1 # This is a copy
464
499
  assert_equal :new_foo1, s1.name # Changed
465
500
  assert_equal 'abracadabra', s1.code # Changed
466
501
  assert_equal [1,2,3], s1.rgb # Unchanged
467
502
 
468
503
  s2 = @style1.variant(:new_foo2, :increment=>-15)
469
504
  assert_instance_of HighLine::Style, s2
470
- assert_not_same @style1, s2 # This is a copy
505
+ refute_same @style1, s2 # This is a copy
471
506
  assert_equal :new_foo2, s2.name # Changed
472
507
  assert_equal "\e[84m", s2.code # 99 (original code) - 15
473
508
  assert_equal [1,2,3], s2.rgb # Unchanged
474
509
 
475
510
  s3 = @style1.variant(:new_foo3, :code=>"\e[55m", :increment=>15)
476
511
  assert_instance_of HighLine::Style, s3
477
- assert_not_same @style1, s3 # This is a copy
512
+ refute_same @style1, s3 # This is a copy
478
513
  assert_equal :new_foo3, s3.name # Changed
479
514
  assert_equal "\e[70m", s3.code # 99 (new code) + 15
480
515
  assert_equal [1,2,3], s3.rgb # Unchanged
481
516
 
482
517
  s4 = @style1.variant(:new_foo4, :code=>"\e[55m", :increment=>15, :rgb=>"blah")
483
518
  assert_instance_of HighLine::Style, s4
484
- assert_not_same @style1, s4 # This is a copy
519
+ refute_same @style1, s4 # This is a copy
485
520
  assert_equal :new_foo4, s4.name # Changed
486
521
  assert_equal "\e[70m", s4.code # 99 (new code) + 15
487
522
  assert_equal 'blah', s4.rgb # Changed
488
523
 
489
524
  s5 = @style1.variant(:new_foo5)
490
525
  assert_instance_of HighLine::Style, s5
491
- assert_not_same @style1, s5 # This is a copy
526
+ refute_same @style1, s5 # This is a copy
492
527
  assert_equal :new_foo5, s5.name # Changed
493
528
  assert_equal "\e[99m", s5.code # Unchanged
494
529
  assert_equal [1,2,3], s5.rgb # Unchanged
@@ -498,7 +533,7 @@ class TestStyle < Test::Unit::TestCase
498
533
  assert_equal style1_code, @style1.code
499
534
  assert_equal style1_rgb, @style1.rgb
500
535
 
501
- assert_raise(::RuntimeError) { @style3.variant(:new_foo6) } # Can't create a variant of a list style
536
+ assert_raises(::RuntimeError) { @style3.variant(:new_foo6) } # Can't create a variant of a list style
502
537
  end
503
538
 
504
539
  def test_on
@@ -508,7 +543,7 @@ class TestStyle < Test::Unit::TestCase
508
543
 
509
544
  s1 = @style1.on
510
545
  assert_instance_of HighLine::Style, s1
511
- assert_not_same @style1, s1 # This is a copy
546
+ refute_same @style1, s1 # This is a copy
512
547
  assert_equal :on_foo, s1.name # Changed
513
548
  assert_equal "\e[109m", s1.code # Changed
514
549
  assert_equal [1,2,3], s1.rgb # Unchanged
@@ -518,7 +553,7 @@ class TestStyle < Test::Unit::TestCase
518
553
  assert_equal style1_code, @style1.code
519
554
  assert_equal style1_rgb, @style1.rgb
520
555
 
521
- assert_raise(::RuntimeError) { @style3.on } # Can't create a variant of a list style
556
+ assert_raises(::RuntimeError) { @style3.on } # Can't create a variant of a list style
522
557
  end
523
558
 
524
559
  def test_bright
@@ -528,7 +563,7 @@ class TestStyle < Test::Unit::TestCase
528
563
 
529
564
  s1 = @style1.bright
530
565
  assert_instance_of HighLine::Style, s1
531
- assert_not_same @style1, s1 # This is a copy
566
+ refute_same @style1, s1 # This is a copy
532
567
  assert_equal :bright_foo, s1.name # Changed
533
568
  assert_equal "\e[159m", s1.code # Changed
534
569
  assert_equal [129,130,131], s1.rgb # Changed
@@ -541,7 +576,7 @@ class TestStyle < Test::Unit::TestCase
541
576
  s2_base = HighLine::Style.new(:name=>:leia, :code=>"\e[92m", :rgb=>[0,0,14])
542
577
  s2 = s2_base.bright
543
578
  assert_instance_of HighLine::Style, s2
544
- assert_not_same s2_base, s2 # This is a copy
579
+ refute_same s2_base, s2 # This is a copy
545
580
  assert_equal :bright_leia, s2.name # Changed
546
581
  assert_equal "\e[152m", s2.code # Changed
547
582
  assert_equal [0,0,142], s2.rgb # Changed
@@ -549,7 +584,7 @@ class TestStyle < Test::Unit::TestCase
549
584
  s3_base = HighLine::Style.new(:name=>:luke, :code=>"\e[93m", :rgb=>[20,21,0])
550
585
  s3 = s3_base.bright
551
586
  assert_instance_of HighLine::Style, s3
552
- assert_not_same s3_base, s3 # This is a copy
587
+ refute_same s3_base, s3 # This is a copy
553
588
  assert_equal :bright_luke, s3.name # Changed
554
589
  assert_equal "\e[153m", s3.code # Changed
555
590
  assert_equal [148,149,0], s3.rgb # Changed
@@ -557,19 +592,19 @@ class TestStyle < Test::Unit::TestCase
557
592
  s4_base = HighLine::Style.new(:name=>:r2d2, :code=>"\e[94m", :rgb=>[0,0,0])
558
593
  s4 = s4_base.bright
559
594
  assert_instance_of HighLine::Style, s4
560
- assert_not_same s4_base, s4 # This is a copy
595
+ refute_same s4_base, s4 # This is a copy
561
596
  assert_equal :bright_r2d2, s4.name # Changed
562
597
  assert_equal "\e[154m", s4.code # Changed
563
598
  assert_equal [128,128,128], s4.rgb # Changed; special case
564
599
 
565
- assert_raise(::RuntimeError) { @style3.bright } # Can't create a variant of a list style
600
+ assert_raises(::RuntimeError) { @style3.bright } # Can't create a variant of a list style
566
601
  end
567
602
 
568
603
  def test_light_do_the_same_as_bright
569
604
  bright_style = @style1.bright
570
605
  light_style = @style1.light
571
606
 
572
- assert_not_equal bright_style, light_style
607
+ refute_equal bright_style, light_style
573
608
  assert_equal :bright_foo, bright_style.name
574
609
  assert_equal :light_foo, light_style.name
575
610
  assert_equal bright_style.code, light_style.code