Skip to content

Instantly share code, notes, and snippets.

@amiel
Created October 11, 2013 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiel/6927952 to your computer and use it in GitHub Desktop.
Save amiel/6927952 to your computer and use it in GitHub Desktop.
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
+ class TestCase < ::ActiveSupport::TestCase
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment