Sha256: 98aeb3578178c4aefd779be3663be759b913e3618f0551ed5be4c6a7f19ab133

Contents?: true

Size: 977 Bytes

Versions: 1

Compression:

Stored size: 977 Bytes

Contents

require 'dslkit/polite'
require 'test/unit'

class FromModuleTest < Test::Unit::TestCase
  module MyIncludedModule
    def foo
      :foo
    end

    def bar
      :bar
    end
  end

  class MyKlass
    def foo
      :original_foo
    end

    def bar
      :original_bar
    end
  end

  class DerivedKlass < MyKlass
    extend DSLKit::FromModule

    include from :module => MyIncludedModule, :methods => [ :foo ]
  end

  module MyModule
    def foo
      :original_foo
    end

    def bar
      :original_bar
    end
    include MyIncludedModule
  end

  class AnotherDerivedKlass
    include MyModule

    extend DSLKit::FromModule

    include from :module => MyIncludedModule, :methods => :foo
  end

  def test_derived_klass
    c = DerivedKlass.new
    assert_equal :foo, c.foo
    assert_equal :original_bar, c.bar
  end

  def test_another_derived_klass
    c = AnotherDerivedKlass.new
    assert_equal :foo, c.foo
    assert_equal :original_bar, c.bar
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dslkit-0.2.9 tests/from_module_test.rb