fedora-migrator /vendor/gems/facets-2.4.5/test/more/test_methodspace.rb

Language Ruby Lines 79
MD5 Hash 993e6ad01c24fbd28ad30a4265bf5b1f Estimated Cost $1,334 (why?)
Repository https://bitbucket.org/mediashelf/fedora-migrator View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Test facets/namespace.rb

require 'facets/methodspace.rb'  # to be renamed methodspace.rb (?)
require 'test/unit'

class TestSpaceWithModule < Test::Unit::TestCase

  module M
    def x; "x"; end
  end

  class C
    method_space M
  end

  def test_01
    c = C.new
    assert_equal('x', c.m.x)
  end

  def test_02
    c = C.new
    assert_raises(NoMethodError){ c.x }
  end

end

class TestSpaceWithBlock < Test::Unit::TestCase

  class B
    def x; 1; end
  end

  class C < B
    def x; super; end
    method_space :m do
      def x; "x"; end
    end
  end

  def test_01
    c = C.new
    assert_equal('x', c.m.x)
  end

  def test_02
    c = C.new
    assert_equal(1, c.x)
  end

end

class TestIncludeAs < Test::Unit::TestCase

  module MockModule
    def x; "X"; end
    def y; @y; end
  end

  class MockObject
    include_as :mod => MockModule

    def initialize
      @y = "Y"
    end
  end

  def test_01
    m = MockObject.new
    assert_equal( "X", m.mod.x )
  end

  def test_02
    m = MockObject.new
    assert_equal( "Y", m.mod.y )
  end

end
Back to Top