From c50220619be5c1d83768611a41d27442dd2056de Mon Sep 17 00:00:00 2001 From: k0kubun Date: Wed, 24 Jan 2018 14:31:40 +0000 Subject: [PATCH] system_spec.rb: add RubySpec for r62025 NEWS: added an entry for `exception: true` option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- NEWS | 4 ++++ spec/ruby/core/kernel/system_spec.rb | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/NEWS b/NEWS index 9174577811..4125f07725 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,10 @@ with all sufficient information, see the ChangeLog file or Redmine * added Dir#each_child and Dir#children instance methods. [Feature #13969] +* Kernel + + * Kernel.#system takes :exception option to raise an exception on failure. [Feature #14386] + * Proc * Proc#call doesn't change $SAFE any more. [Feature #14250] diff --git a/spec/ruby/core/kernel/system_spec.rb b/spec/ruby/core/kernel/system_spec.rb index aee75441a2..a3dfbeba05 100644 --- a/spec/ruby/core/kernel/system_spec.rb +++ b/spec/ruby/core/kernel/system_spec.rb @@ -25,6 +25,14 @@ describe :kernel_system, shared: true do $?.exitstatus.should == 1 end + it "raises RuntimeError when `exception: true` is given and the command exits with a non-zero exit status" do + lambda { @object.system(ruby_cmd('exit 1'), exception: true) }.should raise_error(RuntimeError) + end + + it "raises Errno::ENOENT when `exception: true` is given and the specified command does not exist" do + lambda { @object.system('feature_14386', exception: true) }.should raise_error(Errno::ENOENT) + end + it "returns nil when command execution fails" do @object.system("sad").should be_nil