@@ -291,29 +291,41 @@ def file
291
291
end
292
292
end
293
293
294
- describe "aborting on failure" do
294
+ describe "when pretending" do
295
+ it "doesn't execute the command" do
296
+ runner = MyCounter . new ( [ 1 ] , %w( --pretend ) )
297
+ expect ( runner ) . not_to receive ( :system )
298
+ runner . run ( "ls" , :verbose => false )
299
+ end
300
+ end
301
+
302
+ describe "when not capturing" do
295
303
it "aborts when abort_on_failure is given and command fails" do
296
304
expect { action :run , "false" , :abort_on_failure => true } . to raise_error ( SystemExit )
297
305
end
298
306
299
- it "suceeds when abort_on_failure is given and command succeeds" do
307
+ it "succeeds when abort_on_failure is given and command succeeds" do
300
308
expect { action :run , "true" , :abort_on_failure => true } . not_to raise_error
301
309
end
302
310
311
+ it "supports env option" do
312
+ expect { action :run , "echo $BAR" , :env => { "BAR" => "foo" } } . to output ( "foo\n " ) . to_stdout_from_any_process
313
+ end
314
+ end
315
+
316
+ describe "when capturing" do
303
317
it "aborts when abort_on_failure is given, capture is given and command fails" do
304
318
expect { action :run , "false" , :abort_on_failure => true , :capture => true } . to raise_error ( SystemExit )
305
319
end
306
320
307
- it "suceeds when abort_on_failure is given and command succeeds" do
321
+ it "succeeds when abort_on_failure is given and command succeeds" do
308
322
expect { action :run , "true" , :abort_on_failure => true , :capture => true } . not_to raise_error
309
323
end
310
- end
311
324
312
- describe "when pretending" do
313
- it "doesn't execute the command" do
314
- runner = MyCounter . new ( [ 1 ] , %w( --pretend ) )
315
- expect ( runner ) . not_to receive ( :system )
316
- runner . run ( "ls" , :verbose => false )
325
+ it "supports env option" do
326
+ silence ( :stdout ) do
327
+ expect ( runner . run "echo $BAR" , :env => { "BAR" => "foo" } , :capture => true ) . to eq ( "foo\n " )
328
+ end
317
329
end
318
330
end
319
331
end
@@ -367,8 +379,8 @@ def file
367
379
end
368
380
369
381
it "captures the output when :capture is given" do
370
- expect ( runner ) . to receive ( :` ) . with ( "thor foo bar" )
371
- action ( :thor , "foo" , "bar" , :capture => true )
382
+ expect ( runner ) . to receive ( :run ) . with ( "list" , hash_including ( :capture => true ) )
383
+ action :thor , :list , :capture => true
372
384
end
373
385
end
374
386
end
0 commit comments