Sha256: 56a41efcd6d3ae187418d25805b1b302ddfa12cd7069017c4f2cc47c94256f17

Contents?: true

Size: 1020 Bytes

Versions: 3

Compression:

Stored size: 1020 Bytes

Contents

module MiniTestSpecRails
  module DSL

    RAILS_TEST_CASES = []

    def self.included(klass)
      klass.extend ClassMethods
    end

    module ClassMethods

      def before(type = nil, &block)
        setup { self.instance_eval(&block) }
      end

      def after(type = nil, &block)
        teardown { self.instance_eval(&block) }
      end

      def rails_test_cases
        RAILS_TEST_CASES
      end

      def register_rails_test_case(test_case)
        return if RAILS_TEST_CASES.include?(test_case)
        RAILS_TEST_CASES.unshift(test_case)
      end

      def describing_class
        ancestors.detect { |a| Class === a && rails_test_cases.include?(a.superclass) }
      end

      def described_class
        begin
          describing_class.name.gsub(/Test$/, '').constantize
        rescue NameError
          nil
        end
      end
      
    end

    def describing_class
      self.class.describing_class
    end

    def described_class
      self.class.described_class
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
minitest-spec-rails-4.7.2 lib/minitest-spec-rails/dsl.rb
minitest-spec-rails-4.7.1 lib/minitest-spec-rails/dsl.rb
minitest-spec-rails-4.7.0 lib/minitest-spec-rails/dsl.rb