2018-03-04 10:09:32 -05:00
|
|
|
require_relative '../../spec_helper'
|
2017-05-07 08:04:49 -04:00
|
|
|
|
|
|
|
describe "Proc#binding" do
|
|
|
|
it "returns a Binding instance" do
|
2019-07-27 06:40:09 -04:00
|
|
|
[Proc.new{}, -> {}, proc {}].each { |p|
|
2017-05-07 08:04:49 -04:00
|
|
|
p.binding.should be_kind_of(Binding)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns the binding associated with self" do
|
|
|
|
obj = mock('binding')
|
|
|
|
def obj.test_binding(some, params)
|
2019-07-27 06:40:09 -04:00
|
|
|
-> {}
|
2017-05-07 08:04:49 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
lambdas_binding = obj.test_binding(1, 2).binding
|
|
|
|
|
|
|
|
eval("some", lambdas_binding).should == 1
|
|
|
|
eval("params", lambdas_binding).should == 2
|
|
|
|
end
|
|
|
|
end
|