Skip to content

Instantly share code, notes, and snippets.

@unicornrainbow
Created September 26, 2011 18:13
Show Gist options
  • Select an option

  • Save unicornrainbow/1242912 to your computer and use it in GitHub Desktop.

Select an option

Save unicornrainbow/1242912 to your computer and use it in GitHub Desktop.
Fixnum#of
# Example:
#
# 2.of { Factory(:user) } #=> [<User>, <User>]
#
class Fixnum
def of
(1..self).map { |n| yield n }
end
end
require 'spec_helper'
describe Fixnum do
describe "#of" do
result = 2.of { |n| n }
result.should == ([1, 2])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment