We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bbdd2a8 commit 7dbeac1Copy full SHA for 7dbeac1
core/array/flatten_spec.rb
@@ -92,6 +92,30 @@
92
ary.flatten
93
ary.should == [1, [2, 3]]
94
end
95
+
96
+ it "ignores NoMethodError raised by calling to_ary on element with no to_ary method" do
97
+ obj = Object.new
98
+ lambda { [obj].flatten.should == [obj] }.should_not raise_error(NoMethodError)
99
+ end
100
101
+ it "ignores the return value of to_ary if it is nil" do
102
+ obj = Class.new do
103
+ def to_ary
104
+ nil
105
106
+ end.new
107
+ [obj].flatten.should == [obj]
108
109
110
+ it "raises TypeError if return value of to_ary is not an Array" do
111
112
113
+ 1
114
115
116
+ lambda { [obj].flatten }.should raise_error(TypeError)
117
118
119
120
121
describe "Array#flatten!" do
0 commit comments