Sha256: daa462fcc81d5505037f0cdcd83bc773499774cc2721f2a56afb85c4f6c0a336

Contents?: true

Size: 1.04 KB

Versions: 16

Compression:

Stored size: 1.04 KB

Contents

# 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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
facets-2.8.4 test/more/test_methodspace.rb
facets-2.8.3 test/more/test_methodspace.rb
facets-2.8.2 test/more/test_methodspace.rb
facets-2.8.1 test/more/test_methodspace.rb
facets-2.8.0 test/more/test_methodspace.rb
facets-2.7.0 test/more/test_methodspace.rb
facets-2.6.0 test/more/test_methodspace.rb
facets-2.4.0 test/test_methodspace.rb
facets-2.4.1 test/test_methodspace.rb
facets-2.4.4 test/more/test_methodspace.rb
facets-2.4.3 test/more/test_methodspace.rb
facets-2.4.2 test/more/test_methodspace.rb
facets-2.5.0 test/more/test_methodspace.rb
facets-2.5.1 test/more/test_methodspace.rb
facets-2.4.5 test/more/test_methodspace.rb
facets-2.5.2 test/more/test_methodspace.rb