~/talk

Extremely Defensive Coding

Talkat RubyConf 2015 · 2015-11-15..11-17· [ruby, testing]
slides:none on file

Claim: RSpec restores an object's original method after a test so tests don't leave objects broken. The code shown is a defensive wrapper, RSpec::Support.method_handle_for, that grabs method objects even when users override Kernel#method or when interpreters differ. The implementation evolves through checking Kernel, using instance_method, rebinding tricks and fallbacks, and ends up working across many runtimes including MRI 1.8.7, JRuby and REE, so the feature actually operates in real legacy and hybrid deployments.

AI-written summary · about

  1. 0:00Start
  2. 0:11EXTREMELY DEFENSIVE CODING
  3. 6:59Internals?
  4. 19:15Instance method object Method without a target object
  5. 20:08Grab the Kernel implementation of #method
  6. 22:44Rebinding module methods
  7. 23:21RSpec does not support Rubinius
  8. 30:31Interface?
  9. 31:59Minitest Mock is 169 lines of code
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.