@@ -44,7 +44,7 @@ def shell
44
44
45
45
it "prints a message to the user with the available options and reasks the question after an incorrect repsonse" do
46
46
expect ( $stdout) . to receive ( :print ) . with ( 'What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] ' ) . twice
47
- expect ( $stdout) . to receive ( :puts ) . with ( ' Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.' )
47
+ expect ( $stdout) . to receive ( :print ) . with ( " Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n " )
48
48
expect ( $stdin) . to receive ( :gets ) . and_return ( 'moose tracks' , 'chocolate' )
49
49
expect ( shell . ask ( "What's your favorite Neopolitan flavor?" , :limited_to => [ "strawberry" , "chocolate" , "vanilla" ] ) ) . to eq ( "chocolate" )
50
50
end
@@ -57,7 +57,7 @@ def shell
57
57
58
58
it "prints a message to the user with the available options and reasks the question after an incorrect repsonse and then returns the default" do
59
59
expect ( $stdout) . to receive ( :print ) . with ( 'What\'s your favorite Neopolitan flavor? [strawberry, chocolate, vanilla] (vanilla) ' ) . twice
60
- expect ( $stdout) . to receive ( :puts ) . with ( ' Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.' )
60
+ expect ( $stdout) . to receive ( :print ) . with ( " Your response must be one of: [strawberry, chocolate, vanilla]. Please try again.\n " )
61
61
expect ( $stdin) . to receive ( :gets ) . and_return ( 'moose tracks' , '' )
62
62
expect ( shell . ask ( "What's your favorite Neopolitan flavor?" , :default => "vanilla" , :limited_to => [ "strawberry" , "chocolate" , "vanilla" ] ) ) . to eq ( "vanilla" )
63
63
end
@@ -89,7 +89,7 @@ def shell
89
89
90
90
describe "#say" do
91
91
it "prints a message to the user" do
92
- expect ( $stdout) . to receive ( :puts ) . with ( "Running..." )
92
+ expect ( $stdout) . to receive ( :print ) . with ( "Running...\n " )
93
93
shell . say ( "Running..." )
94
94
end
95
95
@@ -99,7 +99,7 @@ def shell
99
99
end
100
100
101
101
it "does not use a new line with whitespace+newline embedded" do
102
- expect ( $stdout) . to receive ( :puts ) . with ( "It's \n Running..." )
102
+ expect ( $stdout) . to receive ( :print ) . with ( "It's \n Running...\n " )
103
103
shell . say ( "It's \n Running..." )
104
104
end
105
105
@@ -111,18 +111,18 @@ def shell
111
111
112
112
describe "#say_status" do
113
113
it "prints a message to the user with status" do
114
- expect ( $stdout) . to receive ( :puts ) . with ( " create ~/.thor/command.thor" )
114
+ expect ( $stdout) . to receive ( :print ) . with ( " create ~/.thor/command.thor\n " )
115
115
shell . say_status ( :create , "~/.thor/command.thor" )
116
116
end
117
117
118
118
it "always uses new line" do
119
- expect ( $stdout) . to receive ( :puts ) . with ( " create " )
119
+ expect ( $stdout) . to receive ( :print ) . with ( " create \n " )
120
120
shell . say_status ( :create , "" )
121
121
end
122
122
123
123
it "does not print a message if base is muted" do
124
124
expect ( shell ) . to receive ( :mute? ) . and_return ( true )
125
- expect ( $stdout) . not_to receive ( :puts )
125
+ expect ( $stdout) . not_to receive ( :print )
126
126
127
127
shell . mute do
128
128
shell . say_status ( :created , "~/.thor/command.thor" )
@@ -133,19 +133,19 @@ def shell
133
133
base = MyCounter . new [ 1 , 2 ]
134
134
expect ( base ) . to receive ( :options ) . and_return ( :quiet => true )
135
135
136
- expect ( $stdout) . not_to receive ( :puts )
136
+ expect ( $stdout) . not_to receive ( :print )
137
137
shell . base = base
138
138
shell . say_status ( :created , "~/.thor/command.thor" )
139
139
end
140
140
141
141
it "does not print a message if log status is set to false" do
142
- expect ( $stdout) . not_to receive ( :puts )
142
+ expect ( $stdout) . not_to receive ( :print )
143
143
shell . say_status ( :created , "~/.thor/command.thor" , false )
144
144
end
145
145
146
146
it "uses padding to set message's left margin" do
147
147
shell . padding = 2
148
- expect ( $stdout) . to receive ( :puts ) . with ( " create ~/.thor/command.thor" )
148
+ expect ( $stdout) . to receive ( :print ) . with ( " create ~/.thor/command.thor\n " )
149
149
shell . say_status ( :create , "~/.thor/command.thor" )
150
150
end
151
151
end
@@ -293,7 +293,7 @@ def #456 Lanç...
293
293
294
294
it "quits if the user chooses quit" do
295
295
allow ( $stdout) . to receive ( :print )
296
- expect ( $stdout) . to receive ( :puts ) . with ( ' Aborting...' )
296
+ expect ( $stdout) . to receive ( :print ) . with ( " Aborting...\n " )
297
297
expect ( $stdin) . to receive ( :gets ) . and_return ( 'q' )
298
298
299
299
expect {
0 commit comments