Sha256: 26c89b2fec00d4c5f8b3cb080eef864042671e99b1abea607ed83eca53b659c2

Contents?: true

Size: 915 Bytes

Versions: 12

Compression:

Stored size: 915 Bytes

Contents

require File.dirname(__FILE__) + '/helper'

class ErnieTest < Test::Unit::TestCase
  module TestExposingModule
    def foo
    end

    def bar(a, b, c=nil)
      [a, b, c]
    end

  protected
    def baz
    end

  private
    def bling
    end
  end

  context "expose" do
    setup { Ernie.expose :expo, TestExposingModule }
    teardown { Ernie.mods.clear }

    should "add all public methods from the module" do
      assert_not_nil Ernie.mods[:expo].funs[:foo]
      assert_not_nil Ernie.mods[:expo].funs[:bar]
    end

    should "not expose protected methods" do
      assert_nil Ernie.mods[:expo].funs[:baz]
    end

    should "not expose private methods" do
      assert_nil Ernie.mods[:expo].funs[:bling]
    end

    should "dispatch to module methods properly" do
      res = Ernie.dispatch(:expo, :bar, ['a', :b, { :fiz => 42 }])
      assert_equal ['a', :b, { :fiz => 42 }], res
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
ernie-2.5.2 test/test_ernie.rb
ernie-2.5.1 test/test_ernie.rb
ernie-2.5.0 test/test_ernie.rb
ernie-2.4.0 test/ernie_test.rb
ernie-2.3.0 test/ernie_test.rb
ernie-2.2.1 test/ernie_test.rb
schleyfox-ernie-2.2.3 test/ernie_test.rb
schleyfox-ernie-2.2.2 test/ernie_test.rb
schleyfox-ernie-2.2.1 test/ernie_test.rb
ernie-2.2.0 test/ernie_test.rb
ernie-2.1.0 test/ernie_test.rb
ernie-2.0.0 test/ernie_test.rb