diff options
Diffstat (limited to 'spec/ruby/core/array/bsearch_spec.rb')
| -rw-r--r-- | spec/ruby/core/array/bsearch_spec.rb | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/spec/ruby/core/array/bsearch_spec.rb b/spec/ruby/core/array/bsearch_spec.rb index 8fa6245dbf..12aec60654 100644 --- a/spec/ruby/core/array/bsearch_spec.rb +++ b/spec/ruby/core/array/bsearch_spec.rb @@ -3,26 +3,26 @@ require_relative '../enumerable/shared/enumeratorized' describe "Array#bsearch" do it "returns an Enumerator when not passed a block" do - [1].bsearch.should be_an_instance_of(Enumerator) + [1].bsearch.should.instance_of?(Enumerator) end it_behaves_like :enumeratorized_with_unknown_size, :bsearch, [1,2,3] it "raises a TypeError if the block returns an Object" do - -> { [1].bsearch { Object.new } }.should raise_error(TypeError) + -> { [1].bsearch { Object.new } }.should.raise(TypeError) end it "raises a TypeError if the block returns a String" do - -> { [1].bsearch { "1" } }.should raise_error(TypeError) + -> { [1].bsearch { "1" } }.should.raise(TypeError) end context "with a block returning true or false" do it "returns nil if the block returns false for every element" do - [0, 1, 2, 3].bsearch { |x| x > 3 }.should be_nil + [0, 1, 2, 3].bsearch { |x| x > 3 }.should == nil end it "returns nil if the block returns nil for every element" do - [0, 1, 2, 3].bsearch { |x| nil }.should be_nil + [0, 1, 2, 3].bsearch { |x| nil }.should == nil end it "returns element at zero if the block returns true for every element" do @@ -38,21 +38,21 @@ describe "Array#bsearch" do context "with a block returning negative, zero, positive numbers" do it "returns nil if the block returns less than zero for every element" do - [0, 1, 2, 3].bsearch { |x| x <=> 5 }.should be_nil + [0, 1, 2, 3].bsearch { |x| x <=> 5 }.should == nil end it "returns nil if the block returns greater than zero for every element" do - [0, 1, 2, 3].bsearch { |x| x <=> -1 }.should be_nil + [0, 1, 2, 3].bsearch { |x| x <=> -1 }.should == nil end it "returns nil if the block never returns zero" do - [0, 1, 3, 4].bsearch { |x| x <=> 2 }.should be_nil + [0, 1, 3, 4].bsearch { |x| x <=> 2 }.should == nil end it "accepts (+/-)Float::INFINITY from the block" do - [0, 1, 3, 4].bsearch { |x| Float::INFINITY }.should be_nil - [0, 1, 3, 4].bsearch { |x| -Float::INFINITY }.should be_nil + [0, 1, 3, 4].bsearch { |x| Float::INFINITY }.should == nil + [0, 1, 3, 4].bsearch { |x| -Float::INFINITY }.should == nil end it "returns an element at an index for which block returns 0.0" do @@ -62,17 +62,17 @@ describe "Array#bsearch" do it "returns an element at an index for which block returns 0" do result = [0, 1, 2, 3, 4].bsearch { |x| x < 1 ? 1 : x > 3 ? -1 : 0 } - [1, 2].should include(result) + [1, 2].should.include?(result) end end context "with a block that calls break" do it "returns nil if break is called without a value" do - ['a', 'b', 'c'].bsearch { |v| break }.should be_nil + ['a', 'b', 'c'].bsearch { |v| break }.should == nil end it "returns nil if break is called with a nil value" do - ['a', 'b', 'c'].bsearch { |v| break nil }.should be_nil + ['a', 'b', 'c'].bsearch { |v| break nil }.should == nil end it "returns object if break is called with an object" do |
