diff options
author | Scott Bronson <brons_git@rinspin.com> | 2016-02-25 02:42:21 -0800 |
---|---|---|
committer | Scott Bronson <brons_git@rinspin.com> | 2016-03-07 11:38:43 -0800 |
commit | 4ca01d95f6a26d0f65fa23b2a64ca32ec8ea8567 (patch) | |
tree | ee94c9dae4ccaa1baedab7afc7674ffe914dfb44 /actionpack/lib | |
parent | 96e25060461aadaff7fd6504bb26e7f5df03d4d3 (diff) | |
download | rails-4ca01d95f6a26d0f65fa23b2a64ca32ec8ea8567.tar.gz rails-4ca01d95f6a26d0f65fa23b2a64ca32ec8ea8567.tar.bz2 rails-4ca01d95f6a26d0f65fa23b2a64ca32ec8ea8567.zip |
extract ActionDispatch::IntegrationTest::Behavior
Similar to 176fbfd6, this makes it possible for other test
frameworks to hook into Rails integration test facilities.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/testing/integration.rb | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/actionpack/lib/action_dispatch/testing/integration.rb b/actionpack/lib/action_dispatch/testing/integration.rb index b0b5db704b..60c562d7cd 100644 --- a/actionpack/lib/action_dispatch/testing/integration.rb +++ b/actionpack/lib/action_dispatch/testing/integration.rb @@ -735,36 +735,49 @@ module ActionDispatch # Consult the Rails Testing Guide for more. class IntegrationTest < ActiveSupport::TestCase - include Integration::Runner - include ActionController::TemplateAssertions - include ActionDispatch::Routing::UrlFor + module UrlOptions + extend ActiveSupport::Concern + def url_options + integration_session.url_options + end + end - @@app = nil + module Behavior + extend ActiveSupport::Concern - def self.app - @@app || ActionDispatch.test_app - end + include Integration::Runner + include ActionController::TemplateAssertions - def self.app=(app) - @@app = app - end + included do + include ActionDispatch::Routing::UrlFor + include UrlOptions # don't let UrlFor override the url_options method + ActiveSupport.run_load_hooks(:action_dispatch_integration_test, self) + @@app = nil + end - def app - super || self.class.app - end + module ClassMethods + def app + defined?(@@app) ? @@app : ActionDispatch.test_app + end - def url_options - integration_session.url_options - end + def app=(app) + @@app = app + end - def document_root_element - html_document.root - end + def register_encoder(*args) + Integration::Session::RequestEncoder.register_encoder(*args) + end + end + + def app + super || self.class.app + end - def self.register_encoder(*args) - Integration::Session::RequestEncoder.register_encoder(*args) + def document_root_element + html_document.root + end end - ActiveSupport.run_load_hooks(:action_dispatch_integration_test, self) + include Behavior end end |