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
This commit is contained in:
k0kubun 2018-01-24 14:31:40 +00:00
parent fb29cffab0
commit c50220619b
2 changed files with 12 additions and 0 deletions

4
NEWS
View File

@ -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]

View File

@ -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