Sha256: 4f608fe143a9dbbb5e106e79b8af071dae6263ca239073aa7e5e08ed0b51e01c

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

module Draper
  begin
    require 'minitest/rails'
  rescue LoadError
  end

  active_support_test_case = begin
    require 'minitest/rails/active_support' # minitest-rails < 0.5
    ::MiniTest::Rails::ActiveSupport::TestCase
  rescue LoadError
    require 'active_support/test_case'
    ::ActiveSupport::TestCase
  end

  class TestCase < active_support_test_case
    module ViewContextTeardown
      def teardown
        super
        Draper::ViewContext.clear!
      end
    end

    module Behavior
      if defined?(::Devise)
        require 'draper/test/devise_helper'
        include Draper::DeviseHelper
      end

      if defined?(::Capybara) && (defined?(::RSpec) || defined?(::MiniTest::Matchers))
        require 'capybara/rspec/matchers'
        include ::Capybara::RSpecMatchers
      end

      include Draper::ViewHelpers::ClassMethods
      alias_method :helper, :helpers
    end

    include Behavior
    include ViewContextTeardown
  end
end

if defined?(ActionController::TestCase)
  class ActionController::TestCase
    include Draper::TestCase::ViewContextTeardown
  end
end

if defined?(ActionMailer::TestCase)
  class ActionMailer::TestCase
    include Draper::TestCase::ViewContextTeardown
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
draper-1.3.0 lib/draper/test_case.rb
draper-1.2.1 lib/draper/test_case.rb
draper-1.2.0 lib/draper/test_case.rb
jamesgolick-draper-1.1.1a lib/draper/test_case.rb
draper-1.1.0 lib/draper/test_case.rb