8000 Added some explorative tests for hash loops · ericxtang/recursive-open-struct@4bad711 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4bad711

Browse files
committed
Added some explorative tests for hash loops
1 parent db6f22b commit 4bad711

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

spec/recursive_open_struct_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,20 @@
5959
@ros.blah_as_a_hash.should == { :another => 'value' }
6060
end
6161

62+
describe "handling loops in the origin Hashes" do
63+
before(:each) do
64+
h1 = { :a => 'a'}
65+
h2 = { :a => 'b', :h1 => h1 }
66+
h1[:h2] = h2
67+
@ros = RecursiveOpenStruct.new(h2)
68+
end
69+
70+
it { @ros.h1.a.should == 'a' }
71+
it { @ros.h1.h2.a.should == 'b' }
72+
it { @ros.h1.h2.h1.a.should == 'a' }
73+
it { @ros.h1.h2.h1.h2.a.should == 'b' }
74+
it { @ros.h1.should == @ros.h1.h2.h1 }
75+
it { @ros.h1.should_not == @ros.h1.h2 }
76+
end # describe handling loops in the origin Hashes
6277
end # recursive behavior
6378
end # describe RecursiveOpenStruct

0 commit comments

Comments
 (0)
0