From 3adfa2c8bb5bd2e9bcf6ad8b5407100800ccdec3 Mon Sep 17 00:00:00 2001 From: Joe Ferris Date: Tue, 5 Jul 2011 18:42:57 -0400 Subject: [PATCH] Fixed defined constants interacting in nested contexts --- spec/spec_helper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 42ed2536d..4354ef4ad 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -31,8 +31,8 @@ module DefinesConstants def self.included(example_group) example_group.class_eval do before do - @defined_constants = [] - @created_tables = [] + @defined_constants ||= [] + @created_tables ||= [] end after do @@ -40,12 +40,14 @@ def self.included(example_group) namespace, class_name = *constant_path(path) namespace.send(:remove_const, class_name) end + @defined_constants.clear @created_tables.each do |table_name| ActiveRecord::Base. connection. execute("DROP TABLE IF EXISTS #{table_name}") end + @created_tables.clear end def define_class(path, base = Object, &block)