diff options
Diffstat (limited to 'spec/ruby/core/array/max_spec.rb')
| -rw-r--r-- | spec/ruby/core/array/max_spec.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/spec/ruby/core/array/max_spec.rb b/spec/ruby/core/array/max_spec.rb index cf6a48c2e3..868275a748 100644 --- a/spec/ruby/core/array/max_spec.rb +++ b/spec/ruby/core/array/max_spec.rb @@ -1,6 +1,10 @@ -require File.expand_path('../../../spec_helper', __FILE__) +require_relative '../../spec_helper' describe "Array#max" do + it "is defined on Array" do + [1].method(:max).owner.should.equal? Array + end + it "returns nil with no values" do [].max.should == nil end @@ -64,18 +68,18 @@ describe "Array#max" do end it "raises a NoMethodError for elements without #<=>" do - lambda do + -> do [BasicObject.new, BasicObject.new].max - end.should raise_error(NoMethodError) + end.should.raise(NoMethodError) end it "raises an ArgumentError for incomparable elements" do - lambda do + -> do [11,"22"].max - end.should raise_error(ArgumentError) - lambda do + end.should.raise(ArgumentError) + -> do [11,12,22,33].max{|a, b| nil} - end.should raise_error(ArgumentError) + end.should.raise(ArgumentError) end it "returns the maximum element (with block)" do |
