@@ -190,6 +190,48 @@ def shell
190
190
end
191
191
end
192
192
193
+ describe "#say_error" do
194
+ it "prints a message to the user" do
195
+ expect ( $stderr) . to receive ( :print ) . with ( "Running...\n " )
196
+ shell . say_error ( "Running..." )
197
+ end
198
+
199
+ it "prints a message to the user without new line if it ends with a whitespace" do
200
+ expect ( $stderr) . to receive ( :print ) . with ( "Running... " )
201
+ shell . say_error ( "Running... " )
202
+ end
203
+
204
+ it "does not use a new line with whitespace+newline embedded" do
205
+ expect ( $stderr) . to receive ( :print ) . with ( "It's \n Running...\n " )
206
+ shell . say_error ( "It's \n Running..." )
207
+ end
208
+
209
+ it "prints a message to the user without new line" do
210
+ expect ( $stderr) . to receive ( :print ) . with ( "Running..." )
211
+ shell . say_error ( "Running..." , nil , false )
212
+ end
213
+
214
+ it "coerces everything to a string before printing" do
215
+ expect ( $stderr) . to receive ( :print ) . with ( "this_is_not_a_string\n " )
216
+ shell . say_error ( :this_is_not_a_string , nil , true )
217
+ end
218
+
219
+ it "does not print a message if muted" do
220
+ expect ( $stderr) . not_to receive ( :print )
221
+ shell . mute do
222
+ shell . say_error ( "Running..." )
223
+ end
224
+ end
225
+
226
+ it "does not print a message if base is set to quiet" do
227
+ shell . base = MyCounter . new [ 1 , 2 ]
228
+ expect ( shell . base ) . to receive ( :options ) . and_return ( :quiet => true )
229
+
230
+ expect ( $stderr) . not_to receive ( :print )
231
+ shell . say_error ( "Running..." )
232
+ end
233
+ end
234
+
193
235
describe "#print_wrapped" do
194
236
let ( :message ) do
195
237
"Creates a back-up of the given folder by compressing it in a .tar.gz\n " \
0 commit comments