Skip to content

Commit 0b18cb1

Browse files
bjfisheregon
authored andcommitted
Update Kernel#instance_variables to return insertion order
1 parent 8d6be09 commit 0b18cb1

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

core/kernel/instance_variables_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,16 @@
2525
a.instance_variable_set("@test", 1)
2626
a.instance_variables.should == [:@test]
2727
end
28+
29+
it "returns the instances variables in the order declared" do
30+
c = Class.new do
31+
def initialize
32+
@c = 1
33+
@a = 2
34+
@b = 3
35+
end
36+
end
37+
c.new.instance_variables.should == [:@c, :@a, :@b]
38+
end
2839
end
2940
end

0 commit comments

Comments
 (0)