diff options
Diffstat (limited to 'spec/ruby/core/array/bsearch_index_spec.rb')
| -rw-r--r-- | spec/ruby/core/array/bsearch_index_spec.rb | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/spec/ruby/core/array/bsearch_index_spec.rb b/spec/ruby/core/array/bsearch_index_spec.rb index df2c7c098e..e1d5eb66bb 100644 --- a/spec/ruby/core/array/bsearch_index_spec.rb +++ b/spec/ruby/core/array/bsearch_index_spec.rb @@ -8,11 +8,11 @@ describe "Array#bsearch_index" do end it "returns an Enumerator" do - @enum.should be_an_instance_of(Enumerator) + @enum.should.instance_of?(Enumerator) end it "returns an Enumerator with unknown size" do - @enum.size.should be_nil + @enum.size.should == nil end it "returns index of element when block condition is satisfied" do @@ -21,11 +21,11 @@ describe "Array#bsearch_index" do end it "raises a TypeError when block returns a String" do - -> { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError) + -> { [1, 2, 3].bsearch_index { "not ok" } }.should.raise(TypeError) end it "returns nil when block is empty" do - [1, 2, 3].bsearch_index {}.should be_nil + [1, 2, 3].bsearch_index {}.should == nil end context "minimum mode" do @@ -40,8 +40,8 @@ describe "Array#bsearch_index" do end it "returns nil when block condition is never satisfied" do - @array.bsearch_index { false }.should be_nil - @array.bsearch_index { |x| x >= 100 }.should be_nil + @array.bsearch_index { false }.should == nil + @array.bsearch_index { |x| x >= 100 }.should == nil end end @@ -51,34 +51,30 @@ describe "Array#bsearch_index" do end it "returns the index of any matched elements where element is between 4 <= x < 8" do - [1, 2].should include(@array.bsearch_index { |x| 1 - x / 4 }) + [1, 2].should.include?(@array.bsearch_index { |x| 1 - x / 4 }) end it "returns the index of any matched elements where element is between 8 <= x < 10" do - @array.bsearch_index { |x| 4 - x / 2 }.should be_nil + @array.bsearch_index { |x| 4 - x / 2 }.should == nil end it "returns nil when block never returns 0" do - @array.bsearch_index { |x| 1 }.should be_nil - @array.bsearch_index { |x| -1 }.should be_nil - end - - it "returns the middle element when block always returns zero" do - @array.bsearch_index { |x| 0 }.should == 2 + @array.bsearch_index { |x| 1 }.should == nil + @array.bsearch_index { |x| -1 }.should == nil end context "magnitude does not effect the result" do it "returns the index of any matched elements where element is between 4n <= xn < 8n" do - [1, 2].should include(@array.bsearch_index { |x| (1 - x / 4) * (2**100) }) + [1, 2].should.include?(@array.bsearch_index { |x| (1 - x / 4) * (2**100) }) end it "returns nil when block never returns 0" do - @array.bsearch_index { |x| 1 * (2**100) }.should be_nil - @array.bsearch_index { |x| (-1) * (2**100) }.should be_nil + @array.bsearch_index { |x| 1 * (2**100) }.should == nil + @array.bsearch_index { |x| (-1) * (2**100) }.should == nil end it "handles values from Integer#coerce" do - [1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first }) + [1, 2].should.include?(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first }) end end end |
