Skip to content

Instantly share code, notes, and snippets.

@cronin101
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save cronin101/9529205 to your computer and use it in GitHub Desktop.

Select an option

Save cronin101/9529205 to your computer and use it in GitHub Desktop.
Test Driven Definition: Behaviour assertions in decorators example.
def must_contain_plus meth
raise unless RubyVM::InstructionSequence.disasm(method(meth)).include? 'opt_plus'
meth
end
must_contain_plus(
def add(x, y)
x + y
end)
#=> :add
must_contain_plus(
def mult(x, y)
x * y
end)
#=> RuntimeError:
# from (pry):21:in `must_contain_plus'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment