diff options
Diffstat (limited to 'spec/ruby/core/process/getrlimit_spec.rb')
| -rw-r--r-- | spec/ruby/core/process/getrlimit_spec.rb | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/spec/ruby/core/process/getrlimit_spec.rb b/spec/ruby/core/process/getrlimit_spec.rb index 7924d43081..d36d8c3335 100644 --- a/spec/ruby/core/process/getrlimit_spec.rb +++ b/spec/ruby/core/process/getrlimit_spec.rb @@ -1,8 +1,8 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' platform_is :aix do # In AIX, if getrlimit(2) is called multiple times with RLIMIT_DATA, - # the first call and the subequent calls return slightly different + # the first call and the subsequent calls return slightly different # values of rlim_cur, even if the process does nothing between # the calls. This behavior causes some of the tests in this spec # to fail, so call Process.getrlimit(:DATA) once and discard the result. @@ -11,13 +11,13 @@ platform_is :aix do Process.getrlimit(:DATA) end -platform_is_not :windows do - describe "Process.getrlimit" do +describe "Process.getrlimit" do + platform_is_not :windows do it "returns a two-element Array of Integers" do result = Process.getrlimit Process::RLIMIT_CORE result.size.should == 2 - result.first.should be_kind_of(Integer) - result.last.should be_kind_of(Integer) + result.first.should.is_a?(Integer) + result.last.should.is_a?(Integer) end context "when passed an Object" do @@ -36,33 +36,33 @@ platform_is_not :windows do obj = mock("process getrlimit integer") obj.should_receive(:to_int).and_return(nil) - lambda { Process.getrlimit(obj) }.should raise_error(TypeError) + -> { Process.getrlimit(obj) }.should.raise(TypeError) end end context "when passed a Symbol" do - Process.constants.grep(/\ARLIMIT_/) do |fullname| - short = $' - it "coerces :#{short} into #{fullname}" do + it "coerces the short name into the full RLIMIT_ prefixed name" do + Process.constants.grep(/\ARLIMIT_/) do |fullname| + short = fullname[/\ARLIMIT_(.+)/, 1] Process.getrlimit(short.to_sym).should == Process.getrlimit(Process.const_get(fullname)) end end it "raises ArgumentError when passed an unknown resource" do - lambda { Process.getrlimit(:FOO) }.should raise_error(ArgumentError) + -> { Process.getrlimit(:FOO) }.should.raise(ArgumentError) end end context "when passed a String" do - Process.constants.grep(/\ARLIMIT_/) do |fullname| - short = $' - it "coerces '#{short}' into #{fullname}" do + it "coerces the short name into the full RLIMIT_ prefixed name" do + Process.constants.grep(/\ARLIMIT_/) do |fullname| + short = fullname[/\ARLIMIT_(.+)/, 1] Process.getrlimit(short).should == Process.getrlimit(Process.const_get(fullname)) end end it "raises ArgumentError when passed an unknown resource" do - lambda { Process.getrlimit("FOO") }.should raise_error(ArgumentError) + -> { Process.getrlimit("FOO") }.should.raise(ArgumentError) end end @@ -88,4 +88,13 @@ platform_is_not :windows do end end end + + platform_is :windows do + it "is not implemented" do + Process.respond_to?(:getrlimit).should == false + -> do + Process.getrlimit(nil) + end.should.raise NotImplementedError + end + end end |
