summaryrefslogtreecommitdiff
path: root/test/test_menu.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_menu.rb')
-rw-r--r--test/test_menu.rb174
1 files changed, 87 insertions, 87 deletions
diff --git a/test/test_menu.rb b/test/test_menu.rb
index 402b47d..514ff6b 100644
--- a/test/test_menu.rb
+++ b/test/test_menu.rb
@@ -90,7 +90,7 @@ class TestMenu < Minitest::Test
# Default: menu.flow = :rows
menu.choice "Unicode right single quotation mark: ’"
end
- assert_equal("1. Unicode right single quotation mark: ’\n? ".encode(@output.external_encoding, { :undef => :replace }), @output.string)
+ assert_equal("1. Unicode right single quotation mark: ’\n? ".encode(@output.external_encoding, undef: :replace), @output.string)
end
def test_text_override_index_selects_name
@@ -102,8 +102,8 @@ class TestMenu < Minitest::Test
menu.choice("Sample2", nil, "Sample1")
end
assert_equal(selected, "Sample1")
- assert_equal("1. Sample2\n" +
- "2. Sample1\n" +
+ assert_equal("1. Sample2\n" \
+ "2. Sample1\n" \
"? ", @output.string)
end
@@ -116,8 +116,8 @@ class TestMenu < Minitest::Test
menu.choice("Sample2", nil, "Sample1")
end
assert_equal(selected, "Sample2")
- assert_equal("1. Sample2\n" +
- "2. Sample1\n" +
+ assert_equal("1. Sample2\n" \
+ "2. Sample1\n" \
"? ", @output.string)
end
@@ -130,8 +130,8 @@ class TestMenu < Minitest::Test
menu.add_item(HighLine::Menu::Item.new("Sample2", text: "Sample1"))
end
assert_equal(selected, "Sample1")
- assert_equal("1. Sample2\n" +
- "2. Sample1\n" +
+ assert_equal("1. Sample2\n" \
+ "2. Sample1\n" \
"? ", @output.string)
end
@@ -144,8 +144,8 @@ class TestMenu < Minitest::Test
menu.add_item(HighLine::Menu::Item.new("Sample2", text: "Sample1"))
end
assert_equal(selected, "Sample2")
- assert_equal("1. Sample2\n" +
- "2. Sample1\n" +
+ assert_equal("1. Sample2\n" \
+ "2. Sample1\n" \
"? ", @output.string)
end
@@ -158,8 +158,8 @@ class TestMenu < Minitest::Test
menu.add_item(menu.build_item("Sample2", text: "Sample1"))
end
assert_equal(selected, "Sample2")
- assert_equal("1. Sample2\n" +
- "2. Sample1\n" +
+ assert_equal("1. Sample2\n" \
+ "2. Sample1\n" \
"? ", @output.string)
end
@@ -178,22 +178,22 @@ class TestMenu < Minitest::Test
menu.help("rules", "The rules of this system are as follows...")
end
end
- assert_equal( "1. load\n2. save\n3. quit\n4. help\n? " +
- "This command will display helpful messages about " +
- "functionality, like this one. To see the help for a " +
- "specific topic enter:\n" +
- "\thelp [TOPIC]\n" +
- "Try asking for help on any of the following:\n" +
- "\nload quit rules save \n" +
- "1. load\n2. save\n3. quit\n4. help\n? " +
- "= load\n\n" +
- "Load a file.\n" +
- "1. load\n2. save\n3. quit\n4. help\n? " +
- "= rules\n\n" +
- "The rules of this system are as follows...\n" +
- "1. load\n2. save\n3. quit\n4. help\n? " +
- "= missing\n\n" +
- "There's no help for that topic.\n", @output.string )
+ assert_equal("1. load\n2. save\n3. quit\n4. help\n? " \
+ "This command will display helpful messages about " \
+ "functionality, like this one. To see the help for a " \
+ "specific topic enter:\n" \
+ "\thelp [TOPIC]\n" \
+ "Try asking for help on any of the following:\n" \
+ "\nload quit rules save \n" \
+ "1. load\n2. save\n3. quit\n4. help\n? " \
+ "= load\n\n" \
+ "Load a file.\n" \
+ "1. load\n2. save\n3. quit\n4. help\n? " \
+ "= rules\n\n" \
+ "The rules of this system are as follows...\n" \
+ "1. load\n2. save\n3. quit\n4. help\n? " \
+ "= missing\n\n" \
+ "There's no help for that topic.\n", @output.string)
end
def test_index
@@ -238,7 +238,7 @@ class TestMenu < Minitest::Test
@input.rewind
@terminal.choose do |menu|
- menu.index = "*"
+ menu.index = "*"
menu.choice "Sample1"
menu.choice "Sample2"
@@ -265,7 +265,7 @@ class TestMenu < Minitest::Test
assert_equal(
HighLine.color("1. ", index_color) + "Sample1\n" +
HighLine.color("2. ", index_color) + "Sample2\n" +
- HighLine.color("3. ", index_color) + "Sample3\n" +
+ HighLine.color("3. ", index_color) + "Sample3\n" \
"? ",
@output.string
)
@@ -323,8 +323,8 @@ class TestMenu < Minitest::Test
colored_asterix = HighLine.color("* ", index_color)
assert_equal(
- "#{colored_asterix}Sample1\n" +
- "#{colored_asterix}Sample2\n" +
+ "#{colored_asterix}Sample1\n" \
+ "#{colored_asterix}Sample2\n" \
"#{colored_asterix}Sample3\n? ",
@output.string
)
@@ -343,8 +343,8 @@ class TestMenu < Minitest::Test
@terminal.choose(:load, :save, :quit) do |menu|
menu.header = "File Menu"
end
- assert_equal( "File Menu:\n" +
- "1. load\n2. save\n3. quit\n? ", @output.string )
+ assert_equal("File Menu:\n" \
+ "1. load\n2. save\n3. quit\n? ", @output.string)
@input.rewind
@output.truncate(@output.rewind)
@@ -354,14 +354,14 @@ class TestMenu < Minitest::Test
menu.header = "File Menu"
menu.prompt = "Operation? "
end
- assert_equal( "File Menu: Operation? " +
- "(load, save or quit) ", @output.string )
+ assert_equal("File Menu: Operation? " \
+ "(load, save or quit) ", @output.string)
@input.rewind
@output.truncate(@output.rewind)
@terminal.choose(:load, :save, :quit) do |menu|
- menu.layout = :menu_only
+ menu.layout = :menu_only
end
assert_equal("load, save or quit? ", @output.string)
@@ -391,9 +391,9 @@ class TestMenu < Minitest::Test
# Shows that by default proc results are returned.
output = @terminal.choose do |menu|
- menu.choice "Sample1" do "output1" end
- menu.choice "Sample2" do "output2" end
- menu.choice "Sample3" do "output3" end
+ menu.choice "Sample1" do "output1" end
+ menu.choice "Sample2" do "output2" end
+ menu.choice "Sample3" do "output3" end
end
assert_equal("output3", output)
@@ -402,10 +402,10 @@ class TestMenu < Minitest::Test
# _nil_on_handled to +true+.
#
output = @terminal.choose do |menu|
- menu.nil_on_handled = true
- menu.choice "Sample1" do "output1" end
- menu.choice "Sample2" do "output2" end
- menu.choice "Sample3" do "output3" end
+ menu.nil_on_handled = true
+ menu.choice "Sample1" do "output1" end
+ menu.choice "Sample2" do "output2" end
+ menu.choice "Sample3" do "output3" end
end
assert_equal(nil, output)
@@ -445,7 +445,7 @@ class TestMenu < Minitest::Test
menu.character = :getc
end
assert_equal(:Save, answer)
- assert_equal(?a, @input.getc)
+ assert_equal('a', @input.getc)
end
def test_select_by
@@ -527,7 +527,7 @@ class TestMenu < Minitest::Test
@input.rewind
selected = @terminal.choose do |menu|
- menu.index = :letter
+ menu.index = :letter
menu.choice :save
menu.choice :load
menu.choice :quit
@@ -596,12 +596,12 @@ class TestMenu < Minitest::Test
assert_equal(selected, 3)
# Make sure paging message appeared
- assert( @output.string.index('press enter/return to continue or q to stop'),
- "Paging message did not appear." )
+ assert(@output.string.index('press enter/return to continue or q to stop'),
+ "Paging message did not appear.")
# Make sure it only appeared once
- assert( @output.string !~ /q to stop.*q to stop/m,
- "Paging message appeared more than once." )
+ assert(@output.string !~ /q to stop.*q to stop/m,
+ "Paging message appeared more than once.")
end
def test_autocomplete_prompt
@@ -614,13 +614,13 @@ class TestMenu < Minitest::Test
menu.choice(:Ruby)
menu.prompt = "What is your favorite programming language? "
end
- languages = [:Perl, :Python, :Ruby]
- assert_equal("1. Perl\n" +
- "2. Python\n" +
- "3. Ruby\n" +
- "What is your favorite programming language? " +
- "You must choose one of [1, 2, 3, Perl, Python, Ruby].\n" +
- "? ", @output.string )
+ languages = %i[Perl Python Ruby]
+ assert_equal("1. Perl\n" \
+ "2. Python\n" \
+ "3. Ruby\n" \
+ "What is your favorite programming language? " \
+ "You must choose one of [1, 2, 3, Perl, Python, Ruby].\n" \
+ "? ", @output.string)
end
# Issue #180 - https://github.com/JEG2/highline/issues/180
@@ -652,14 +652,14 @@ class TestMenu < Minitest::Test
menu.choice "Sample2"
menu.choice "last"
end
- assert_equal(["Sample1", "last"], selected)
+ assert_equal(%w[Sample1 last], selected)
- assert_equal("1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
- "? 1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
+ assert_equal("1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
+ "? 1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
"? ", @output.string)
end
@@ -675,12 +675,12 @@ class TestMenu < Minitest::Test
end
assert_equal(["Sample1"], selected)
- assert_equal("1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
- "? 1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
+ assert_equal("1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
+ "? 1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
"? ", @output.string)
end
@@ -696,12 +696,12 @@ class TestMenu < Minitest::Test
end
assert_equal(["Sample1"], selected)
- assert_equal("1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
- "? 1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
+ assert_equal("1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
+ "? 1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
"? ", @output.string)
end
@@ -717,12 +717,12 @@ class TestMenu < Minitest::Test
end
assert_equal(["Sample1"], selected)
- assert_equal("1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
- "? 1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
+ assert_equal("1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
+ "? 1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
"? ", @output.string)
end
@@ -738,12 +738,12 @@ class TestMenu < Minitest::Test
end
assert_equal({ "First" => "Sample1", second: "last" }, selected)
- assert_equal("1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
- "? 1. Sample1\n" +
- "2. Sample2\n" +
- "3. last\n" +
+ assert_equal("1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
+ "? 1. Sample1\n" \
+ "2. Sample2\n" \
+ "3. last\n" \
"? ", @output.string)
end
end