Sha256: c7770ba63a7f6cc085b59de91ab54fd16f51e440248fa145dfe18d05a1cc1697
Contents?: true
Size: 806 Bytes
Versions: 1
Compression:
Stored size: 806 Bytes
Contents
require 'test/unit' require 'double' module Foo class << self attr_accessor :double end end class TestDouble < Test::Unit::TestCase def test_lazy_evaluate assert_raise NameError do Foo.class_eval 'self.double = Bar' end Foo.extend Double Foo.class_eval 'self.double = Bar' assert_raise NameError do Foo.double.baz end Kernel.const_set :Bar, Module.new assert_raise NoMethodError do Bar.baz end assert_raise NoMethodError do Foo.double.baz end Bar.class_eval { def self.baz; 1; end } assert_equal 1, Bar.baz assert_equal 1, Foo.double.baz end def test_memoize Double::Klass.class_eval { def method_missing(*args); 2; end } assert_equal 1, Foo.double.baz assert_equal 2, Foo.double.qux end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
double-0.1.0 | test/test_double.rb |