diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-28 19:50:06 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-28 19:50:06 +0000 |
commit | 4fbb9aa3cb6c31ec128bfb31f59efa66d66adba4 (patch) | |
tree | 84a654b260261fe172f2584f60b3ba93e59f841d /spec/ruby/core/array | |
parent | b864bd05bff2a61d55b08deb92e969f9fa55e07c (diff) | |
download | ruby-4fbb9aa3cb6c31ec128bfb31f59efa66d66adba4.tar.gz |
Update to ruby/spec@6f38a82
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/array')
-rw-r--r-- | spec/ruby/core/array/bsearch_index_spec.rb | 118 | ||||
-rw-r--r-- | spec/ruby/core/array/dig_spec.rb | 96 | ||||
-rw-r--r-- | spec/ruby/core/array/flatten_spec.rb | 10 | ||||
-rw-r--r-- | spec/ruby/core/array/pack/j_spec.rb | 306 | ||||
-rw-r--r-- | spec/ruby/core/array/shared/delete_if.rb | 24 | ||||
-rw-r--r-- | spec/ruby/core/array/shared/inspect.rb | 21 |
6 files changed, 270 insertions, 305 deletions
diff --git a/spec/ruby/core/array/bsearch_index_spec.rb b/spec/ruby/core/array/bsearch_index_spec.rb index 49c9d9ea34..a075d06ed3 100644 --- a/spec/ruby/core/array/bsearch_index_spec.rb +++ b/spec/ruby/core/array/bsearch_index_spec.rb @@ -1,86 +1,84 @@ require_relative '../../spec_helper' require_relative '../enumerable/shared/enumeratorized' -ruby_version_is "2.3" do - describe "Array#bsearch_index" do - context "when not passed a block" do - before :each do - @enum = [1, 2, 42, 100, 666].bsearch_index - end +describe "Array#bsearch_index" do + context "when not passed a block" do + before :each do + @enum = [1, 2, 42, 100, 666].bsearch_index + end - it "returns an Enumerator" do - @enum.should be_an_instance_of(Enumerator) - end + it "returns an Enumerator" do + @enum.should be_an_instance_of(Enumerator) + end - it "returns an Enumerator with unknown size" do - @enum.size.should be_nil - end + it "returns an Enumerator with unknown size" do + @enum.size.should be_nil + end - it "returns index of element when block condition is satisfied" do - @enum.each { |x| x >= 33 }.should == 2 - end + it "returns index of element when block condition is satisfied" do + @enum.each { |x| x >= 33 }.should == 2 end + end + + it "raises a TypeError when block returns a String" do + lambda { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError) + end - it "raises a TypeError when block returns a String" do - lambda { [1, 2, 3].bsearch_index { "not ok" } }.should raise_error(TypeError) + it "returns nil when block is empty" do + [1, 2, 3].bsearch_index {}.should be_nil + end + + context "minimum mode" do + before :each do + @array = [0, 4, 7, 10, 12] end - it "returns nil when block is empty" do - [1, 2, 3].bsearch_index {}.should be_nil + it "returns index of first element which satisfies the block" do + @array.bsearch_index { |x| x >= 4 }.should == 1 + @array.bsearch_index { |x| x >= 6 }.should == 2 + @array.bsearch_index { |x| x >= -1 }.should == 0 end - context "minimum mode" do - before :each do - @array = [0, 4, 7, 10, 12] - 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 + end + end - it "returns index of first element which satisfies the block" do - @array.bsearch_index { |x| x >= 4 }.should == 1 - @array.bsearch_index { |x| x >= 6 }.should == 2 - @array.bsearch_index { |x| x >= -1 }.should == 0 - end + context "find any mode" do + before :each do + @array = [0, 4, 7, 10, 12] + 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 - 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 }) end - context "find any mode" do - before :each do - @array = [0, 4, 7, 10, 12] - 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 + 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 }) - 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 index of any matched elements where element is between 8 <= x < 10" do - @array.bsearch_index { |x| 4 - x / 2 }.should be_nil - end + it "returns the middle element when block always returns zero" do + @array.bsearch_index { |x| 0 }.should == 2 + 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 + 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) }) end - it "returns the middle element when block always returns zero" do - @array.bsearch_index { |x| 0 }.should == 2 + 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 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) }) - 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 - end - - it "handles values from Bignum#coerce" do - [1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first }) - end + it "handles values from Bignum#coerce" do + [1, 2].should include(@array.bsearch_index { |x| (2**100).coerce((1 - x / 4) * (2**100)).first }) end end end diff --git a/spec/ruby/core/array/dig_spec.rb b/spec/ruby/core/array/dig_spec.rb index 0a47eb0b13..1ace4893ee 100644 --- a/spec/ruby/core/array/dig_spec.rb +++ b/spec/ruby/core/array/dig_spec.rb @@ -1,54 +1,52 @@ require_relative '../../spec_helper' -ruby_version_is '2.3' do - describe "Array#dig" do - - it "returns #at with one arg" do - ['a'].dig(0).should == 'a' - ['a'].dig(1).should be_nil - end - - it "recurses array elements" do - a = [ [ 1, [2, '3'] ] ] - a.dig(0, 0).should == 1 - a.dig(0, 1, 1).should == '3' - a.dig(0, -1, 0).should == 2 - end - - it "returns the nested value specified if the sequence includes a key" do - a = [42, { foo: :bar }] - a.dig(1, :foo).should == :bar - end - - it "raises a TypeError for a non-numeric index" do - lambda { - ['a'].dig(:first) - }.should raise_error(TypeError) - end - - it "raises a TypeError if any intermediate step does not respond to #dig" do - a = [1, 2] - lambda { - a.dig(0, 1) - }.should raise_error(TypeError) - end - - it "raises an ArgumentError if no arguments provided" do - lambda { - [10].dig() - }.should raise_error(ArgumentError) - end - - it "returns nil if any intermediate step is nil" do - a = [[1, [2, 3]]] - a.dig(1, 2, 3).should == nil - end - - it "calls #dig on the result of #at with the remaining arguments" do - h = [[nil, [nil, nil, 42]]] - h[0].should_receive(:dig).with(1, 2).and_return(42) - h.dig(0, 1, 2).should == 42 - end +describe "Array#dig" do + it "returns #at with one arg" do + ['a'].dig(0).should == 'a' + ['a'].dig(1).should be_nil end + + it "recurses array elements" do + a = [ [ 1, [2, '3'] ] ] + a.dig(0, 0).should == 1 + a.dig(0, 1, 1).should == '3' + a.dig(0, -1, 0).should == 2 + end + + it "returns the nested value specified if the sequence includes a key" do + a = [42, { foo: :bar }] + a.dig(1, :foo).should == :bar + end + + it "raises a TypeError for a non-numeric index" do + lambda { + ['a'].dig(:first) + }.should raise_error(TypeError) + end + + it "raises a TypeError if any intermediate step does not respond to #dig" do + a = [1, 2] + lambda { + a.dig(0, 1) + }.should raise_error(TypeError) + end + + it "raises an ArgumentError if no arguments provided" do + lambda { + [10].dig() + }.should raise_error(ArgumentError) + end + + it "returns nil if any intermediate step is nil" do + a = [[1, [2, 3]]] + a.dig(1, 2, 3).should == nil + end + + it "calls #dig on the result of #at with the remaining arguments" do + h = [[nil, [nil, nil, 42]]] + h[0].should_receive(:dig).with(1, 2).and_return(42) + h.dig(0, 1, 2).should == 42 + end + end diff --git a/spec/ruby/core/array/flatten_spec.rb b/spec/ruby/core/array/flatten_spec.rb index a274a01d89..1b7361552a 100644 --- a/spec/ruby/core/array/flatten_spec.rb +++ b/spec/ruby/core/array/flatten_spec.rb @@ -69,12 +69,10 @@ describe "Array#flatten" do [1, z, 6].flatten.should == [1, 2, 3, 4, 5, 6] end - ruby_version_is "2.3" do - it "does not call #to_ary on elements beyond the given level" do - obj = mock("1") - obj.should_not_receive(:to_ary) - [[obj]].flatten(1) - end + it "does not call #to_ary on elements beyond the given level" do + obj = mock("1") + obj.should_not_receive(:to_ary) + [[obj]].flatten(1) end it "returns subclass instance for Array subclasses" do diff --git a/spec/ruby/core/array/pack/j_spec.rb b/spec/ruby/core/array/pack/j_spec.rb index 3a38ef6db7..7b62d5efdf 100644 --- a/spec/ruby/core/array/pack/j_spec.rb +++ b/spec/ruby/core/array/pack/j_spec.rb @@ -4,216 +4,214 @@ require_relative 'shared/basic' require_relative 'shared/numeric_basic' require_relative 'shared/integer' -ruby_version_is '2.3' do - platform_is pointer_size: 64 do - describe "Array#pack with format 'J'" do - it_behaves_like :array_pack_basic, 'J' - it_behaves_like :array_pack_basic_non_float, 'J' - it_behaves_like :array_pack_arguments, 'J' - it_behaves_like :array_pack_numeric_basic, 'J' - it_behaves_like :array_pack_integer, 'J' - end - - describe "Array#pack with format 'j'" do - it_behaves_like :array_pack_basic, 'j' - it_behaves_like :array_pack_basic_non_float, 'j' - it_behaves_like :array_pack_arguments, 'j' - it_behaves_like :array_pack_numeric_basic, 'j' - it_behaves_like :array_pack_integer, 'j' - end +platform_is pointer_size: 64 do + describe "Array#pack with format 'J'" do + it_behaves_like :array_pack_basic, 'J' + it_behaves_like :array_pack_basic_non_float, 'J' + it_behaves_like :array_pack_arguments, 'J' + it_behaves_like :array_pack_numeric_basic, 'J' + it_behaves_like :array_pack_integer, 'J' + end - little_endian do - describe "Array#pack with format 'J'" do - describe "with modifier '_'" do - it_behaves_like :array_pack_64bit_le, 'J_' - end + describe "Array#pack with format 'j'" do + it_behaves_like :array_pack_basic, 'j' + it_behaves_like :array_pack_basic_non_float, 'j' + it_behaves_like :array_pack_arguments, 'j' + it_behaves_like :array_pack_numeric_basic, 'j' + it_behaves_like :array_pack_integer, 'j' + end - describe "with modifier '!'" do - it_behaves_like :array_pack_64bit_le, 'J!' - end + little_endian do + describe "Array#pack with format 'J'" do + describe "with modifier '_'" do + it_behaves_like :array_pack_64bit_le, 'J_' end - describe "Array#pack with format 'j'" do - describe "with modifier '_'" do - it_behaves_like :array_pack_64bit_le, 'j_' - end - - describe "with modifier '!'" do - it_behaves_like :array_pack_64bit_le, 'j!' - end + describe "with modifier '!'" do + it_behaves_like :array_pack_64bit_le, 'J!' end end - big_endian do - describe "Array#pack with format 'J'" do - describe "with modifier '_'" do - it_behaves_like :array_pack_64bit_be, 'J_' - end - - describe "with modifier '!'" do - it_behaves_like :array_pack_64bit_be, 'J!' - end + describe "Array#pack with format 'j'" do + describe "with modifier '_'" do + it_behaves_like :array_pack_64bit_le, 'j_' end - describe "Array#pack with format 'j'" do - describe "with modifier '_'" do - it_behaves_like :array_pack_64bit_be, 'j_' - end - - describe "with modifier '!'" do - it_behaves_like :array_pack_64bit_be, 'j!' - end + describe "with modifier '!'" do + it_behaves_like :array_pack_64bit_le, 'j!' end end + end + big_endian do describe "Array#pack with format 'J'" do - describe "with modifier '<' and '_'" do - it_behaves_like :array_pack_64bit_le, 'J<_' - it_behaves_like :array_pack_64bit_le, 'J_<' - end - - describe "with modifier '<' and '!'" do - it_behaves_like :array_pack_64bit_le, 'J<!' - it_behaves_like :array_pack_64bit_le, 'J!<' + describe "with modifier '_'" do + it_behaves_like :array_pack_64bit_be, 'J_' end - describe "with modifier '>' and '_'" do - it_behaves_like :array_pack_64bit_be, 'J>_' - it_behaves_like :array_pack_64bit_be, 'J_>' - end - - describe "with modifier '>' and '!'" do - it_behaves_like :array_pack_64bit_be, 'J>!' - it_behaves_like :array_pack_64bit_be, 'J!>' + describe "with modifier '!'" do + it_behaves_like :array_pack_64bit_be, 'J!' end end describe "Array#pack with format 'j'" do - describe "with modifier '<' and '_'" do - it_behaves_like :array_pack_64bit_le, 'j<_' - it_behaves_like :array_pack_64bit_le, 'j_<' + describe "with modifier '_'" do + it_behaves_like :array_pack_64bit_be, 'j_' end - describe "with modifier '<' and '!'" do - it_behaves_like :array_pack_64bit_le, 'j<!' - it_behaves_like :array_pack_64bit_le, 'j!<' + describe "with modifier '!'" do + it_behaves_like :array_pack_64bit_be, 'j!' end + end + end - describe "with modifier '>' and '_'" do - it_behaves_like :array_pack_64bit_be, 'j>_' - it_behaves_like :array_pack_64bit_be, 'j_>' - end + describe "Array#pack with format 'J'" do + describe "with modifier '<' and '_'" do + it_behaves_like :array_pack_64bit_le, 'J<_' + it_behaves_like :array_pack_64bit_le, 'J_<' + end - describe "with modifier '>' and '!'" do - it_behaves_like :array_pack_64bit_be, 'j>!' - it_behaves_like :array_pack_64bit_be, 'j!>' - end + describe "with modifier '<' and '!'" do + it_behaves_like :array_pack_64bit_le, 'J<!' + it_behaves_like :array_pack_64bit_le, 'J!<' end - end - platform_is pointer_size: 32 do - describe "Array#pack with format 'J'" do - it_behaves_like :array_pack_basic, 'J' - it_behaves_like :array_pack_basic_non_float, 'J' - it_behaves_like :array_pack_arguments, 'J' - it_behaves_like :array_pack_numeric_basic, 'J' - it_behaves_like :array_pack_integer, 'J' + describe "with modifier '>' and '_'" do + it_behaves_like :array_pack_64bit_be, 'J>_' + it_behaves_like :array_pack_64bit_be, 'J_>' end - describe "Array#pack with format 'j'" do - it_behaves_like :array_pack_basic, 'j' - it_behaves_like :array_pack_basic_non_float, 'j' - it_behaves_like :array_pack_arguments, 'j' - it_behaves_like :array_pack_numeric_basic, 'j' - it_behaves_like :array_pack_integer, 'j' + describe "with modifier '>' and '!'" do + it_behaves_like :array_pack_64bit_be, 'J>!' + it_behaves_like :array_pack_64bit_be, 'J!>' end + end - big_endian do - describe "Array#pack with format 'J'" do - describe "with modifier '_'" do - it_behaves_like :array_pack_32bit_be, 'J_' - end + describe "Array#pack with format 'j'" do + describe "with modifier '<' and '_'" do + it_behaves_like :array_pack_64bit_le, 'j<_' + it_behaves_like :array_pack_64bit_le, 'j_<' + end - describe "with modifier '!'" do - it_behaves_like :array_pack_32bit_be, 'J!' - end - end + describe "with modifier '<' and '!'" do + it_behaves_like :array_pack_64bit_le, 'j<!' + it_behaves_like :array_pack_64bit_le, 'j!<' + end - describe "Array#pack with format 'j'" do - describe "with modifier '_'" do - it_behaves_like :array_pack_32bit_be, 'j_' - end + describe "with modifier '>' and '_'" do + it_behaves_like :array_pack_64bit_be, 'j>_' + it_behaves_like :array_pack_64bit_be, 'j_>' + end - describe "with modifier '!'" do - it_behaves_like :array_pack_32bit_be, 'j!' - end - end + describe "with modifier '>' and '!'" do + it_behaves_like :array_pack_64bit_be, 'j>!' + it_behaves_like :array_pack_64bit_be, 'j!>' end + end +end - little_endian do - describe "Array#pack with format 'J'" do - describe "with modifier '_'" do - it_behaves_like :array_pack_32bit_le, 'J_' - end +platform_is pointer_size: 32 do + describe "Array#pack with format 'J'" do + it_behaves_like :array_pack_basic, 'J' + it_behaves_like :array_pack_basic_non_float, 'J' + it_behaves_like :array_pack_arguments, 'J' + it_behaves_like :array_pack_numeric_basic, 'J' + it_behaves_like :array_pack_integer, 'J' + end - describe "with modifier '!'" do - it_behaves_like :array_pack_32bit_le, 'J!' - end - end + describe "Array#pack with format 'j'" do + it_behaves_like :array_pack_basic, 'j' + it_behaves_like :array_pack_basic_non_float, 'j' + it_behaves_like :array_pack_arguments, 'j' + it_behaves_like :array_pack_numeric_basic, 'j' + it_behaves_like :array_pack_integer, 'j' + end - describe "Array#pack with format 'j'" do - describe "with modifier '_'" do - it_behaves_like :array_pack_32bit_le, 'j_' - end + big_endian do + describe "Array#pack with format 'J'" do + describe "with modifier '_'" do + it_behaves_like :array_pack_32bit_be, 'J_' + end - describe "with modifier '!'" do - it_behaves_like :array_pack_32bit_le, 'j!' - end + describe "with modifier '!'" do + it_behaves_like :array_pack_32bit_be, 'J!' end end - describe "Array#pack with format 'J'" do - describe "with modifier '<' and '_'" do - it_behaves_like :array_pack_32bit_le, 'J<_' - it_behaves_like :array_pack_32bit_le, 'J_<' + describe "Array#pack with format 'j'" do + describe "with modifier '_'" do + it_behaves_like :array_pack_32bit_be, 'j_' end - describe "with modifier '<' and '!'" do - it_behaves_like :array_pack_32bit_le, 'J<!' - it_behaves_like :array_pack_32bit_le, 'J!<' + describe "with modifier '!'" do + it_behaves_like :array_pack_32bit_be, 'j!' end + end + end - describe "with modifier '>' and '_'" do - it_behaves_like :array_pack_32bit_be, 'J>_' - it_behaves_like :array_pack_32bit_be, 'J_>' + little_endian do + describe "Array#pack with format 'J'" do + describe "with modifier '_'" do + it_behaves_like :array_pack_32bit_le, 'J_' end - describe "with modifier '>' and '!'" do - it_behaves_like :array_pack_32bit_be, 'J>!' - it_behaves_like :array_pack_32bit_be, 'J!>' + describe "with modifier '!'" do + it_behaves_like :array_pack_32bit_le, 'J!' end end describe "Array#pack with format 'j'" do - describe "with modifier '<' and '_'" do - it_behaves_like :array_pack_32bit_le, 'j<_' - it_behaves_like :array_pack_32bit_le, 'j_<' + describe "with modifier '_'" do + it_behaves_like :array_pack_32bit_le, 'j_' end - describe "with modifier '<' and '!'" do - it_behaves_like :array_pack_32bit_le, 'j<!' - it_behaves_like :array_pack_32bit_le, 'j!<' + describe "with modifier '!'" do + it_behaves_like :array_pack_32bit_le, 'j!' end + end + end - describe "with modifier '>' and '_'" do - it_behaves_like :array_pack_32bit_be, 'j>_' - it_behaves_like :array_pack_32bit_be, 'j_>' - end + describe "Array#pack with format 'J'" do + describe "with modifier '<' and '_'" do + it_behaves_like :array_pack_32bit_le, 'J<_' + it_behaves_like :array_pack_32bit_le, 'J_<' + end - describe "with modifier '>' and '!'" do - it_behaves_like :array_pack_32bit_be, 'j>!' - it_behaves_like :array_pack_32bit_be, 'j!>' - end + describe "with modifier '<' and '!'" do + it_behaves_like :array_pack_32bit_le, 'J<!' + it_behaves_like :array_pack_32bit_le, 'J!<' + end + + describe "with modifier '>' and '_'" do + it_behaves_like :array_pack_32bit_be, 'J>_' + it_behaves_like :array_pack_32bit_be, 'J_>' + end + + describe "with modifier '>' and '!'" do + it_behaves_like :array_pack_32bit_be, 'J>!' + it_behaves_like :array_pack_32bit_be, 'J!>' + end + end + + describe "Array#pack with format 'j'" do + describe "with modifier '<' and '_'" do + it_behaves_like :array_pack_32bit_le, 'j<_' + it_behaves_like :array_pack_32bit_le, 'j_<' + end + + describe "with modifier '<' and '!'" do + it_behaves_like :array_pack_32bit_le, 'j<!' + it_behaves_like :array_pack_32bit_le, 'j!<' + end + + describe "with modifier '>' and '_'" do + it_behaves_like :array_pack_32bit_be, 'j>_' + it_behaves_like :array_pack_32bit_be, 'j_>' + end + + describe "with modifier '>' and '!'" do + it_behaves_like :array_pack_32bit_be, 'j>!' + it_behaves_like :array_pack_32bit_be, 'j!>' end end end diff --git a/spec/ruby/core/array/shared/delete_if.rb b/spec/ruby/core/array/shared/delete_if.rb index a9fb57e0d9..a3fdcf4fac 100644 --- a/spec/ruby/core/array/shared/delete_if.rb +++ b/spec/ruby/core/array/shared/delete_if.rb @@ -3,25 +3,11 @@ describe :delete_if, shared: true do @object = [1,2,3] end - ruby_version_is "2.3" do - it "updates the receiver after all blocks" do - @object.send(@method) do |e| - @object.length.should == 3 - true - end - @object.length.should == 0 - end - end - - ruby_version_is ""..."2.3" do - it "updates the receiver after each true block" do - count = 0 - @object.send(@method) do |e| - @object.length.should == (3 - count) - count += 1 - true - end - @object.length.should == 0 + it "updates the receiver after all blocks" do + @object.send(@method) do |e| + @object.length.should == 3 + true end + @object.length.should == 0 end end diff --git a/spec/ruby/core/array/shared/inspect.rb b/spec/ruby/core/array/shared/inspect.rb index 0cf5035b37..1bcc9f9ca8 100644 --- a/spec/ruby/core/array/shared/inspect.rb +++ b/spec/ruby/core/array/shared/inspect.rb @@ -121,24 +121,11 @@ describe :array_inspect, shared: true do array.send(@method).encoding.name.should == "US-ASCII" end - ruby_version_is ''...'2.3' do - it "raises if inspected result is not default external encoding" do - utf_16be = mock("utf_16be") - utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE)) - - lambda { - [utf_16be].send(@method) - }.should raise_error(Encoding::CompatibilityError) - end - end - - ruby_version_is '2.3' do - it "does not raise if inspected result is not default external encoding" do - utf_16be = mock("utf_16be") - utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE)) + it "does not raise if inspected result is not default external encoding" do + utf_16be = mock("utf_16be") + utf_16be.should_receive(:inspect).and_return(%<"utf_16be \u3042">.encode!(Encoding::UTF_16BE)) - [utf_16be].send(@method).should == '["utf_16be \u3042"]' - end + [utf_16be].send(@method).should == '["utf_16be \u3042"]' end end end |