Sha256: 033f5221ef83ffa4ecf70070bc925b5c5038585365d5bf90340fbe78fac2b650

Contents?: true

Size: 1.82 KB

Versions: 52

Compression:

Stored size: 1.82 KB

Contents

require File.expand_path('../../../../spec_helper', __FILE__)

describe :kernel_method, :shared => true do
  it "returns a method object for a valid method" do
    class KernelSpecs::Foo; def bar; 'done'; end; end
    m = KernelSpecs::Foo.new.send(@method, :bar)
    m.should be_an_instance_of Method
    m.call.should == 'done'
  end

  it "returns a method object for a valid singleton method" do
    class KernelSpecs::Foo; def self.bar; 'class done'; end; end
    m = KernelSpecs::Foo.send(@method, :bar)
    m.should be_an_instance_of Method
    m.call.should == 'class done'
  end

  ruby_version_is "1.9" do
    it "returns a method object if we repond_to_missing? method" do
      class KernelSpecs::Foo;
        def respond_to_missing?(method, priv=false)
          method == :we_handle_this
        end
      end
      m = KernelSpecs::RespondViaMissing.new.method(:handled_publicly)
      m.should be_an_instance_of Method
      #m.call(42).should == "Done handled_publicly([42])"
    end
  end

  it "raises a NameError for an invalid method name" do
    class KernelSpecs::Foo; def bar; 'done'; end; end
    lambda {
      KernelSpecs::Foo.new.send(@method, :invalid_and_silly_method_name)
    }.should raise_error(NameError)
  end

  it "raises a NameError for an invalid singleton method name" do
    class KernelSpecs::Foo; def self.bar; 'done'; end; end
    lambda { KernelSpecs::Foo.send(@method, :baz) }.should raise_error(NameError)
  end

  ruby_bug "redmine:1151", "1.8.7" do
    it "changes the method called for super on a target aliased method" do
      c1 = Class.new do
        def a; 'a'; end
        def b; 'b'; end
      end
      c2 = Class.new(c1) do
        def a; super; end
        alias b a
      end

      c2.new.a.should == 'a'
      c2.new.b.should == 'a'
      c2.new.send(@method, :b).call.should == 'a'
    end
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-7.5.1 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-7.4.1 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-7.1.17 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-6.2.0 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-6.0.11 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-5.5.18 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-5.5.17 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-5.5.15 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-5.5.2 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-5.5.0 spec/framework_spec/app/spec/core/kernel/shared/method.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/core/kernel/shared/method.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/core/kernel/shared/method.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-3.3.5 spec/framework_spec/app/spec/core/kernel/shared/method.rb
rhodes-3.4.2 spec/framework_spec/app/spec/core/kernel/shared/method.rb