Skip to content

Instantly share code, notes, and snippets.

@9z0b3t1c
Created June 21, 2012 21:43
Show Gist options
  • Save 9z0b3t1c/2968719 to your computer and use it in GitHub Desktop.
Save 9z0b3t1c/2968719 to your computer and use it in GitHub Desktop.
require 'rspec'
class MyEnums
def my_map(arr)
result = []
arr.each{|a| result << a*2}
result
end
end
describe MyEnums, "#my_map" do
before(:each) do
@arr = [1,2,3,4]
end
it "doubles each value in the array, just like map" do
myenum = MyEnums.new
myenum.my_map(@arr).should == @arr.map{ |a| a*2 }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment