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-1.15.0 test/method_missing_test.rb
backports-1.14.1 test/method_missing_test.rb
backports-1.14.0 test/method_missing_test.rb
backports-1.13.3 test/method_missing_test.rb
backports-1.13.2 test/method_missing_test.rb
backports-1.13.1 test/method_missing_test.rb
backports-1.13.0 test/method_missing_test.rb
backports-1.12.3 test/method_missing_test.rb
backports-1.12.2 test/method_missing_test.rb
backports-1.12.1 test/method_missing_test.rb
backports-1.12.0 test/method_missing_test.rb
backports-1.11.2 test/method_missing_test.rb
backports-1.11.1 test/method_missing_test.rb
backports-1.11.0 test/method_missing_test.rb
backports-1.10.3 test/method_missing_test.rb
backports-1.10.2 test/method_missing_test.rb
backports-1.10.1 test/method_missing_test.rb
backports-1.10.0 test/method_missing_test.rb