Permalink
Browse files

Correctly initialize the first test after dynamically calling define_…

…models.

Signed-off-by: rick <technoweenie@gmail.com>
  • Loading branch information...
1 parent 5f2268b commit 4d5df0e91900176f21a155a10d885572194e8c9a Darrick Wiebe committed with Feb 10, 2009
Showing with 7 additions and 0 deletions.
  1. +7 −0 lib/model_stubbing/model.rb
@@ -99,6 +99,13 @@ def #{@plural}(key, attrs = {})
end
end
klass.module_eval { define_models name }
+ unless klass.definition_inserted
+ klass.definition.insert!
+ # Don't want to set definition_inserted to true because it will
+ # roll back at the end of the first test. The next test will
+ # correctly insert again before the transaction begins.
+ end
+ klass.definition.setup_test_run
end
klass.definition.models[#{@plural.inspect}].retrieve_record(key, attrs)
end

0 comments on commit 4d5df0e

Please sign in to comment.