patbenatar / ruby-spy

Test spies for Ruby. For fun.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Restore state of spied on objects after example

patbenatar opened this issue · comments

Block format to auto-cleanup:

Spy.clean do
  spy = Spy.on(...)
end

Manual cleanup:

spy = Spy.on(...)
spy.clean

# or globally:
spy_1 = Spy.on(...)
spy_2 = Spy.on(...)
Spy.clean

Each spy should:

  • register themselves globally with Spy (consider threading...)
  • track their dirty state and expose a #dirty? method
  • implement a #clean method

Spy should:

  • implement .clean to clean all dirty registered spies
  • implement .contained to automatically clean up after block execution