Sha256: 6d4f545c914673b3da922692b1e05bf7d95950cac20c4e17e3ab92d2f387033c

Contents?: true

Size: 839 Bytes

Versions: 38

Compression:

Stored size: 839 Bytes

Contents

require 'test_helper'


class MethodMissingTest < Test::Unit::TestCase
  
  class A
    def respond_to_missing? method
      :ok_if_missing == method
    end

    def method_missing method, *args
      :bar
    end
  end

  context "#respond_to?" do
    should "takes #respond_to_missing? into account" do
      assert_equal true, A.new.respond_to?(:ok_if_missing)
      assert_equal false, A.new.respond_to?(:not_ok_if_missing)
    end
  end
  
  context "#method" do
    should "returns a nice Method with respond_to_missing?" do
      assert_equal :bar, A.new.method(:ok_if_missing).call
      assert_raise(NameError){ A.new.method(:not_ok_if_missing) }
    end
  end

  context "Method#unbind" do
    should "works for missing Methods" do
      assert_equal :ok_if_missing, A.new.method(:ok_if_missing).unbind.name
    end
  end


end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
backports-2.3.0 test/method_missing_test.rb
backports-2.2.1 test/method_missing_test.rb
backports-2.2.0 test/method_missing_test.rb
backports-2.1.0 test/method_missing_test.rb
backports-2.0.3 test/method_missing_test.rb
backports-2.0.2 test/method_missing_test.rb
backports-2.0.1 test/method_missing_test.rb
backports-2.0.0 test/method_missing_test.rb
backports-1.18.2 test/method_missing_test.rb
backports-1.18.1 test/method_missing_test.rb
backports-1.18.0 test/method_missing_test.rb
backports-1.17.1 test/method_missing_test.rb
backports-1.17.0 test/method_missing_test.rb
backports-1.16.7 test/method_missing_test.rb
backports-1.16.6 test/method_missing_test.rb
backports-1.16.5 test/method_missing_test.rb
backports-1.16.4 test/method_missing_test.rb
backports-1.16.3 test/method_missing_test.rb
backports-1.16.2 test/method_missing_test.rb
backports-1.16.1 test/method_missing_test.rb