Module: AktionTest::Support::ClassBuilder

Defined in:
lib/aktion_test/support/class_builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(example_group) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/aktion_test/support/class_builder.rb', line 4

def self.included(example_group)
  example_group.class_eval do
    after do
      teardown_defined_constants
    end
  end
end

Instance Method Details

#define_class(class_name, base = Object, scope = Object, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/aktion_test/support/class_builder.rb', line 12

def define_class(class_name, base = Object, scope = Object, &block)
  class_name = class_name.to_s.camelize

  Class.new(base).tap do |constant_class|
    scope.const_set(class_name, constant_class)
    constant_class.unloadable
    constant_class.class_eval(&block) if block_given?
    constant_class.reset_column_information if constant_class.respond_to? :reset_column_information
  end
end

#teardown_defined_constantsObject



23
24
25
# File 'lib/aktion_test/support/class_builder.rb', line 23

def teardown_defined_constants
  ActiveSupport::Dependencies.clear
end