I want to make a Test::Unit test_helper method that I can call to wipe a bunch of tables after the tests execute. Here's the general idea I have:
def self.wipe_models(*models)
def teardown
models.each do |model|
model = model.to_s.camelize.constantize
model.connection.execute "delete from #{model.table_name}"
end
end
end
However, when teardown
runs, I get:
undefined local variable or method `models'
To me it looks like the "def" block doesn't obey usual rules for closures; I can't access variables defined outside of its scope.
So, how do I access a variable that's defined outside of a "def" method declaration?