Skip to content

Commit 0def4cf

Browse files
committed
fix expectations for ruby 3 treatment of hash arg
1 parent eea0955 commit 0def4cf

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

spec/line_editor_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
describe ".readline" do
1414
it "uses the Readline line editor" do
1515
editor = double("Readline")
16-
expect(Thor::LineEditor::Readline).to receive(:new).with("Enter your name ", :default => "Brian").and_return(editor)
16+
expect(Thor::LineEditor::Readline).to receive(:new).with("Enter your name ", {:default => "Brian"}).and_return(editor)
1717
expect(editor).to receive(:readline).and_return("George")
1818
expect(Thor::LineEditor.readline("Enter your name ", :default => "Brian")).to eq("George")
1919
end
@@ -35,7 +35,7 @@
3535
describe ".readline" do
3636
it "uses the Basic line editor" do
3737
editor = double("Basic")
38-
expect(Thor::LineEditor::Basic).to receive(:new).with("Enter your name ", :default => "Brian").and_return(editor)
38+
expect(Thor::LineEditor::Basic).to receive(:new).with("Enter your name ", {:default => "Brian"}).and_return(editor)
3939
expect(editor).to receive(:readline).and_return("George")
4040
expect(Thor::LineEditor.readline("Enter your name ", :default => "Brian")).to eq("George")
4141
end

spec/shell/basic_spec.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,80 +70,80 @@ def shell
7070

7171
it "prints a message to the user with the available options, expects case-sensitive matching, and determines the correctness of the answer" do
7272
flavors = %w(strawberry chocolate vanilla)
73-
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors).and_return("chocolate")
73+
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors}).and_return("chocolate")
7474
expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors)).to eq("chocolate")
7575
end
7676

7777
it "prints a message to the user with the available options, expects case-sensitive matching, and reasks the question after an incorrect response" do
7878
flavors = %w(strawberry chocolate vanilla)
7979
expect($stdout).to receive(:print).with("Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n")
80-
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors).and_return("moose tracks", "chocolate")
80+
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors}).and_return("moose tracks", "chocolate")
8181
expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors)).to eq("chocolate")
8282
end
8383

8484
it "prints a message to the user with the available options, expects case-sensitive matching, and reasks the question after a case-insensitive match" do
8585
flavors = %w(strawberry chocolate vanilla)
8686
expect($stdout).to receive(:print).with("Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n")
87-
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors).and_return("cHoCoLaTe", "chocolate")
87+
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors}).and_return("cHoCoLaTe", "chocolate")
8888
expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors)).to eq("chocolate")
8989
end
9090

9191
it "prints a message to the user with the available options, expects case-insensitive matching, and determines the correctness of the answer" do
9292
flavors = %w(strawberry chocolate vanilla)
93-
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors, :case_insensitive => true).and_return("CHOCOLATE")
93+
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors, :case_insensitive => true}).and_return("CHOCOLATE")
9494
expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors, :case_insensitive => true)).to eq("chocolate")
9595
end
9696

9797
it "prints a message to the user with the available options, expects case-insensitive matching, and reasks the question after an incorrect response" do
9898
flavors = %w(strawberry chocolate vanilla)
9999
expect($stdout).to receive(:print).with("Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n")
100-
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', :limited_to => flavors, :case_insensitive => true).and_return("moose tracks", "chocolate")
100+
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ', {:limited_to => flavors, :case_insensitive => true}).and_return("moose tracks", "chocolate")
101101
expect(shell.ask('What\'s your favorite Neopolitan flavor?', :limited_to => flavors, :case_insensitive => true)).to eq("chocolate")
102102
end
103103

104104
it "prints a message to the user containing a default and sets the default if only enter is pressed" do
105-
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? (vanilla) ', :default => "vanilla").and_return("")
105+
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? (vanilla) ', {:default => "vanilla"}).and_return("")
106106
expect(shell.ask('What\'s your favorite Neopolitan flavor?', :default => "vanilla")).to eq("vanilla")
107107
end
108108

109109
it "prints a message to the user with the available options and reasks the question after an incorrect response and then returns the default" do
110110
flavors = %w(strawberry chocolate vanilla)
111111
expect($stdout).to receive(:print).with("Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n")
112-
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] (vanilla) ', :default => "vanilla", :limited_to => flavors).and_return("moose tracks", "")
112+
expect(Thor::LineEditor).to receive(:readline).with('What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] (vanilla) ', {:default => "vanilla", :limited_to => flavors}).and_return("moose tracks", "")
113113
expect(shell.ask("What's your favorite Neopolitan flavor?", :default => "vanilla", :limited_to => flavors)).to eq("vanilla")
114114
end
115115
end
116116

117117
describe "#yes?" do
118118
it "asks the user and returns true if the user replies yes" do
119-
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("y")
119+
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("y")
120120
expect(shell.yes?("Should I overwrite it?")).to be true
121121
end
122122

123123
it "asks the user and returns false if the user replies no" do
124-
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("n")
124+
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("n")
125125
expect(shell.yes?("Should I overwrite it?")).not_to be true
126126
end
127127

128128
it "asks the user and returns false if the user replies with an answer other than yes or no" do
129-
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("foobar")
129+
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("foobar")
130130
expect(shell.yes?("Should I overwrite it?")).to be false
131131
end
132132
end
133133

134134
describe "#no?" do
135135
it "asks the user and returns true if the user replies no" do
136-
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("n")
136+
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("n")
137137
expect(shell.no?("Should I overwrite it?")).to be true
138138
end
139139

140140
it "asks the user and returns false if the user replies yes" do
141-
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("Yes")
141+
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("Yes")
142142
expect(shell.no?("Should I overwrite it?")).to be false
143143
end
144144

145145
it "asks the user and returns false if the user replies with an answer other than yes or no" do
146-
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", :add_to_history => false).and_return("foobar")
146+
expect(Thor::LineEditor).to receive(:readline).with("Should I overwrite it? ", {:add_to_history => false}).and_return("foobar")
147147
expect(shell.no?("Should I overwrite it?")).to be false
148148
end
149149
end
@@ -431,13 +431,13 @@ def #456 Lanç...
431431
expect(content).to eq(<<-TABLE)
432432
Name Number Color
433433
Erik 1234567890123 green
434-
TABLE
434+
TABLE
435435
end
436436
end
437437

438438
describe "#file_collision" do
439439
it "shows a menu with options" do
440-
expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqh] ', :add_to_history => false).and_return("n")
440+
expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqh] ', {:add_to_history => false}).and_return("n")
441441
shell.file_collision("foo")
442442
end
443443

@@ -478,7 +478,7 @@ def #456 Lanç...
478478
end
479479

480480
it "always returns true if the user chooses always" do
481-
expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqh] ', :add_to_history => false).and_return("a")
481+
expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqh] ', {:add_to_history => false}).and_return("a")
482482

483483
expect(shell.file_collision("foo")).to be true
484484

@@ -488,7 +488,7 @@ def #456 Lanç...
488488

489489
describe "when a block is given" do
490490
it "displays diff and merge options to the user" do
491-
expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqdhm] ', :add_to_history => false).and_return("s")
491+
expect(Thor::LineEditor).to receive(:readline).with('Overwrite foo? (enter "h" for help) [Ynaqdhm] ', {:add_to_history => false}).and_return("s")
492492
shell.file_collision("foo") {}
493493
end
494494

0 commit comments

Comments
 (0)