Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bbe403e1aa9c
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: aac4d1b7b58d
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Feb 26, 2015

  1. Add Method#curry specs

    ruipserra committed Feb 26, 2015
    Copy the full SHA
    d4ccd81 View commit details
  2. Merge pull request #3331 from ruipserra/add_method_curry_specs_on_2.2

    Add Method#curry specs
    Yorick Peterse committed Feb 26, 2015
    Copy the full SHA
    aac4d1b View commit details
Showing with 42 additions and 0 deletions.
  1. +38 −0 spec/ruby/core/method/curry_spec.rb
  2. +4 −0 spec/tags/ruby/core/method/curry_tags.txt
38 changes: 38 additions & 0 deletions spec/ruby/core/method/curry_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../fixtures/classes', __FILE__)

describe "Method#curry" do

it "returns a curried proc" do
x = Object.new
def x.foo(a,b,c); [a,b,c]; end

c = x.method(:foo).curry
c.should be_kind_of(Proc)
c.(1).(2, 3).should == [1,2,3]
end

describe "with optional arity argument" do
before(:each) do
@obj = MethodSpecs::Methods.new
end

it "returns a curried proc when given correct arity" do
@obj.method(:one_req).curry(1).should be_kind_of(Proc)
@obj.method(:zero_with_splat).curry(100).should be_kind_of(Proc)
@obj.method(:two_req_with_splat).curry(2).should be_kind_of(Proc)
end

it "raises ArgumentError when the method requires less arguments than the given arity" do
lambda { @obj.method(:zero).curry(1) }.should raise_error(ArgumentError)
lambda { @obj.method(:one_req_one_opt).curry(3) }.should raise_error(ArgumentError)
lambda { @obj.method(:two_req_one_opt_with_block).curry(4) }.should raise_error(ArgumentError)
end

it "raises ArgumentError when the method requires more arguments than the given arity" do
lambda { @obj.method(:two_req_with_splat).curry(1) }.should raise_error(ArgumentError)
lambda { @obj.method(:one_req).curry(0) }.should raise_error(ArgumentError)
end
end

end
4 changes: 4 additions & 0 deletions spec/tags/ruby/core/method/curry_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fails:Method#curry returns a curried proc
fails:Method#curry with optional arity argument returns a curried proc when given correct arity
fails:Method#curry with optional arity argument raises ArgumentError when the method requires less arguments than the given arity
fails:Method#curry with optional arity argument raises ArgumentError when the method requires more arguments than the given arity