Skip to content

Commit

Permalink
Fixed defined constants interacting in nested contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
jferris committed Jul 5, 2011
1 parent da96a87 commit 3adfa2c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,23 @@ 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
@defined_constants.reverse.each do |path|
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)
Expand Down

0 comments on commit 3adfa2c

Please sign in to comment.