Skip to content

Commit

Permalink
Add a spec for Hash#to_proc result passed as instance_exec block.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius authored and eregon committed Aug 19, 2016
1 parent 85ebe53 commit 6dafa0b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions core/hash/to_proc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
end
end

context "passed as the block for instance_exec" do
it "always retrieves the original hash's values" do
hash = {foo: 1, bar: 2}
proc = hash.to_proc

hash.instance_exec(:foo, &proc).should == 1

hash2 = {quux: 1}
hash2.instance_exec(:foo, &proc).should == 1
end
end

context "with no stored key" do
it "returns nil" do
@proc.call(@unstored).should be_nil
Expand Down

0 comments on commit 6dafa0b

Please sign in to comment.