Sha256: 8a071a6f90f18f049093b5d3b21dc293f3a9b3f4fe91cdd1b825def3ebf2e67c
Contents?: true
Size: 731 Bytes
Versions: 4
Compression:
Stored size: 731 Bytes
Contents
covers 'facets/proc/to_method' testcase Proc do unit :to_method do o = Object.new tproc = proc { |x| x + 2 } tmeth = tproc.to_method(o, :tryit) tmeth.call(1).assert == 3 o.assert.respond_to?(:tryit) o.tryit(1).assert == 3 end unit :to_method => "with immutable object" do o = :foo tproc = proc{ self } tmeth = tproc.to_method(o, :tryit) tmeth.call.assert == :foo o.assert.respond_to?(:tryit) o.tryit.assert == :foo end unit :to_method => "ensure method is in object scope" do o = Struct.new(:a).new(1) tproc = proc{ a } tmeth = tproc.to_method(o, :tryit) tmeth.call.assert == 1 o.assert.respond_to?(:tryit) o.tryit.assert == 1 end end
Version data entries
4 entries across 4 versions & 1 rubygems