@@ -70,80 +70,80 @@ def shell
70
70
71
71
it "prints a message to the user with the available options, expects case-sensitive matching, and determines the correctness of the answer" do
72
72
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" )
74
74
expect ( shell . ask ( 'What\'s your favorite Neopolitan flavor?' , :limited_to => flavors ) ) . to eq ( "chocolate" )
75
75
end
76
76
77
77
it "prints a message to the user with the available options, expects case-sensitive matching, and reasks the question after an incorrect response" do
78
78
flavors = %w( strawberry chocolate vanilla )
79
79
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" )
81
81
expect ( shell . ask ( 'What\'s your favorite Neopolitan flavor?' , :limited_to => flavors ) ) . to eq ( "chocolate" )
82
82
end
83
83
84
84
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
85
85
flavors = %w( strawberry chocolate vanilla )
86
86
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" )
88
88
expect ( shell . ask ( 'What\'s your favorite Neopolitan flavor?' , :limited_to => flavors ) ) . to eq ( "chocolate" )
89
89
end
90
90
91
91
it "prints a message to the user with the available options, expects case-insensitive matching, and determines the correctness of the answer" do
92
92
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" )
94
94
expect ( shell . ask ( 'What\'s your favorite Neopolitan flavor?' , :limited_to => flavors , :case_insensitive => true ) ) . to eq ( "chocolate" )
95
95
end
96
96
97
97
it "prints a message to the user with the available options, expects case-insensitive matching, and reasks the question after an incorrect response" do
98
98
flavors = %w( strawberry chocolate vanilla )
99
99
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" )
101
101
expect ( shell . ask ( 'What\'s your favorite Neopolitan flavor?' , :limited_to => flavors , :case_insensitive => true ) ) . to eq ( "chocolate" )
102
102
end
103
103
104
104
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 ( "" )
106
106
expect ( shell . ask ( 'What\'s your favorite Neopolitan flavor?' , :default => "vanilla" ) ) . to eq ( "vanilla" )
107
107
end
108
108
109
109
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
110
110
flavors = %w( strawberry chocolate vanilla )
111
111
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" , "" )
113
113
expect ( shell . ask ( "What's your favorite Neopolitan flavor?" , :default => "vanilla" , :limited_to => flavors ) ) . to eq ( "vanilla" )
114
114
end
115
115
end
116
116
117
117
describe "#yes?" do
118
118
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" )
120
120
expect ( shell . yes? ( "Should I overwrite it?" ) ) . to be true
121
121
end
122
122
123
123
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" )
125
125
expect ( shell . yes? ( "Should I overwrite it?" ) ) . not_to be true
126
126
end
127
127
128
128
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" )
130
130
expect ( shell . yes? ( "Should I overwrite it?" ) ) . to be false
131
131
end
132
132
end
133
133
134
134
describe "#no?" do
135
135
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" )
137
137
expect ( shell . no? ( "Should I overwrite it?" ) ) . to be true
138
138
end
139
139
140
140
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" )
142
142
expect ( shell . no? ( "Should I overwrite it?" ) ) . to be false
143
143
end
144
144
145
145
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" )
147
147
expect ( shell . no? ( "Should I overwrite it?" ) ) . to be false
148
148
end
149
149
end
@@ -431,13 +431,13 @@ def #456 Lanç...
431
431
expect ( content ) . to eq ( <<-TABLE )
432
432
Name Number Color
433
433
Erik 1234567890123 green
434
- TABLE
434
+ TABLE
435
435
end
436
436
end
437
437
438
438
describe "#file_collision" do
439
439
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" )
441
441
shell . file_collision ( "foo" )
442
442
end
443
443
@@ -478,7 +478,7 @@ def #456 Lanç...
478
478
end
479
479
480
480
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" )
482
482
483
483
expect ( shell . file_collision ( "foo" ) ) . to be true
484
484
@@ -488,7 +488,7 @@ def #456 Lanç...
488
488
489
489
describe "when a block is given" do
490
490
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" )
492
492
shell . file_collision ( "foo" ) { }
493
493
end
494
494
0 commit comments