Sha256: f4dc0b96b88aadf026c1fc575a75c1f857dc20ef7979c7dac5facc29342ecb85

Contents?: true

Size: 1.6 KB

Versions: 52

Compression:

Stored size: 1.6 KB

Contents

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

describe "UnboundMethod#arity" do
  before(:each) do
    @um = UnboundMethodSpecs::Methods.new
  end

  it "returns the number of arguments accepted by a method, using Method#unbind" do
    @um.method(:one).unbind.arity.should == 0
    @um.method(:two).unbind.arity.should == 1
    @um.method(:three).unbind.arity.should == 2
    @um.method(:four).unbind.arity.should == 2
  end

  it "returns the number arguments accepted by a method, using Module#instance_method" do
    UnboundMethodSpecs::Methods.instance_method(:one).arity.should == 0
    UnboundMethodSpecs::Methods.instance_method(:two).arity.should == 1
    UnboundMethodSpecs::Methods.instance_method(:three).arity.should == 2
    UnboundMethodSpecs::Methods.instance_method(:four).arity.should == 2
  end

  it "if optional arguments returns the negative number of mandatory arguments, using Method#unbind" do
    @um.method(:neg_one).unbind.arity.should == -1
    @um.method(:neg_two).unbind.arity.should == -2
    @um.method(:neg_three).unbind.arity.should == -3
    @um.method(:neg_four).unbind.arity.should == -3
  end

  it "if optional arguments returns the negative number of mandatory arguments, using Module#instance_method" do
    UnboundMethodSpecs::Methods.instance_method(:neg_one).arity.should == -1
    UnboundMethodSpecs::Methods.instance_method(:neg_two).arity.should == -2
    UnboundMethodSpecs::Methods.instance_method(:neg_three).arity.should == -3
    UnboundMethodSpecs::Methods.instance_method(:neg_four).arity.should == -3
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

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