I want to make the Test :: Unit test_helper method, which I can call to erase a bunch of tables after running the tests. Here is a general idea:
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 it teardownworks, I get:
undefined local variable or `models' method
It seems to me that the "def" block does not obey the usual closing rules; I cannot access variables defined outside of his scope.
So, how do I access a variable that is defined outside of the def method declaration?
source
share