Sha256: 93cac4ec4fc12c09e9611ef755f45683566369d94dec688052898c9b493c2538

Contents?: true

Size: 770 Bytes

Versions: 3

Compression:

Stored size: 770 Bytes

Contents

module AktionTest
  module Support
    module ClassBuilder
      def self.included(example_group)
        example_group.class_eval do
          after do
            teardown_defined_constants
          end
        end
      end

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

        Class.new(base).tap do |constant_class|
          Object.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

      def teardown_defined_constants
        ActiveSupport::Dependencies.clear
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aktion_test-0.2.2 lib/aktion_test/support/class_builder.rb
aktion_test-0.2.1 lib/aktion_test/support/class_builder.rb
aktion_test-0.2.0 lib/aktion_test/support/class_builder.rb