This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.

Fixing Bugs in Someone else's Class
CodeExpectedActual
class Multiplier
  def double_your_pleasure(pleasure)
    return pleasure * 3 # FIXME: Actually triples your pleasure.
  end
end
m = Multiplier.new
m.double_your_pleasure(6)
18 18
class Multiplier
  alias :double_your_pleasure_BUGGY double_your_pleasure
  def double_your_pleasure(pleasure)
    return pleasure * 2
  end
end
m.double_your_pleasure(6)
12 12
m.double_your_pleasure_BUGGY(6)
18 18