Sha256: ea2fb14d046282a93eb0a4cb8fa8520d7961bf6b3921d3eb81d5baf30561e89d
Contents?: true
Size: 892 Bytes
Versions: 68
Compression:
Stored size: 892 Bytes
Contents
require 'test_helper' class ObjectTest < Test::Unit::TestCase class KlassWithSecret def initialize @secret = 99 end end context "Object" do context "#instance_exec" do should "conform to doc" do k = KlassWithSecret.new assert_equal 104, k.instance_exec(5) {|x| @secret+x } end end context "#define_singleton_method" do should "conform to doc" do a = "cat" a.define_singleton_method(:speak) do "miaow" end assert_equal "miaow", a.speak KlassWithSecret.class_eval do define_method(:one) { "instance method" } define_singleton_method(:two) { "class method" } end t = KlassWithSecret.new assert_equal "instance method", t.one assert_equal "class method", KlassWithSecret.two end end end end
Version data entries
68 entries across 68 versions & 2 rubygems