Skip to content

Instantly share code, notes, and snippets.

@smtlaissezfaire
Created February 8, 2009 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smtlaissezfaire/60491 to your computer and use it in GitHub Desktop.
Save smtlaissezfaire/60491 to your computer and use it in GitHub Desktop.
def foo(collection)
if collection.empty?
collectionect.first
else
[ collection.first ] + foo_recurse( collection.rest )
end
end
alias_method :foo_recurse, :foo
## spec:
it "should recurse on the rest of the items" do
@obj.should_receive(:foo_recurse).with([2,3,4])
@obj.foo([1,2,3,4])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment