Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Test Your Legacy Code

Noel Rappin
November 07, 2011

Test Your Legacy Code

Presented at RubyMidwest, November 2011

Noel Rappin

November 07, 2011

Transcript

84 slides
  1. Oh. My. God. The last person to work on this

    was an idiot Monday, November 7, 11
  2. Shake your fists at the heavens for one minute. Photo

    by Sha Sha Chu http://www.flickr.com/photos/shashachu/88654315/ Monday, November 7, 11
  3. def crazy_insane_method(arg, arg, new_arg = nil) # crazy insane stuff

    # now with new stuff end Monday, November 7, 11
  4. class TestPurchase < Purchase def bang # no-op end end

    user.purchase << TestPurchase.new Monday, November 7, 11
  5. class TestPurchase def bang # no-op end end user.purchase <<

    TestPurchase.new Monday, November 7, 11
  6. class Pebble def initialize(name) @name = name end def method_missing(method_name,

    *args) p "#{method_name}(#{args.join(", ")}) from #{caller_method}" self end end Monday, November 7, 11
  7. def caller_method(depth = 1) parse_caller(caller(depth+1).first).last end def parse_caller(at) if /^(.+?):(\d+)(?::in

    `(.*)')?/ =~ at file = Regexp.last_match[1] line = Regexp.last_match[2].to_i method = Regexp.last_match[3] [file, line, method] end Monday, November 7, 11

More Decks by Noel Rappin

Other Decks in Technology