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

Version Path
marcandre-backports-1.6.0 test/object_test.rb
marcandre-backports-1.6.1 test/object_test.rb
marcandre-backports-1.6.3 test/object_test.rb
marcandre-backports-1.6.4 test/object_test.rb
marcandre-backports-1.6.6 test/object_test.rb
marcandre-backports-1.6.7 test/object_test.rb
marcandre-backports-1.6.8 test/object_test.rb
marcandre-backports-1.7.0 test/object_test.rb
marcandre-backports-1.7.1 test/object_test.rb
marcandre-backports-1.8.0 test/object_test.rb
marcandre-backports-1.8.1 test/object_test.rb
marcandre-backports-1.8.2 test/object_test.rb
marcandre-backports-1.8.3 test/object_test.rb
marcandre-backports-1.8.4 test/object_test.rb
marcandre-backports-1.9.0 test/object_test.rb
backports-2.3.0 test/object_test.rb
backports-2.2.1 test/object_test.rb
backports-2.2.0 test/object_test.rb
backports-2.1.0 test/object_test.rb
backports-2.0.3 test/object_test.rb