diff options
Diffstat (limited to 'railties/test/application/integration_test_case_test.rb')
-rw-r--r-- | railties/test/application/integration_test_case_test.rb | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/railties/test/application/integration_test_case_test.rb b/railties/test/application/integration_test_case_test.rb index d106d5159a..c08761092b 100644 --- a/railties/test/application/integration_test_case_test.rb +++ b/railties/test/application/integration_test_case_test.rb @@ -1,12 +1,14 @@ -require 'isolation/abstract_unit' +# frozen_string_literal: true + +require "isolation/abstract_unit" +require "env_helpers" module ApplicationTests class IntegrationTestCaseTest < ActiveSupport::TestCase - include ActiveSupport::Testing::Isolation + include ActiveSupport::Testing::Isolation, EnvHelpers setup do build_app - boot_rails end teardown do @@ -14,9 +16,9 @@ module ApplicationTests end test "resets Action Mailer test deliveries" do - script('generate mailer BaseMailer welcome') + rails "generate", "mailer", "BaseMailer", "welcome" - app_file 'test/integration/mailer_integration_test.rb', <<-RUBY + app_file "test/integration/mailer_integration_test.rb", <<-RUBY require 'test_helper' class MailerIntegrationTest < ActionDispatch::IntegrationTest @@ -38,8 +40,36 @@ module ApplicationTests end RUBY - output = Dir.chdir(app_path) { `bin/rails test 2>&1` } - assert_equal 0, $?.to_i, output + with_rails_env("test") { rails("db:migrate") } + output = rails("test") + assert_match(/0 failures, 0 errors/, output) + end + end + + class IntegrationTestDefaultApp < ActiveSupport::TestCase + include ActiveSupport::Testing::Isolation, EnvHelpers + + setup do + build_app + end + + teardown do + teardown_app + end + + test "app method of integration tests returns test_app by default" do + app_file "test/integration/default_app_test.rb", <<-RUBY + require 'test_helper' + + class DefaultAppIntegrationTest < ActionDispatch::IntegrationTest + def test_app_returns_action_dispatch_test_app_by_default + assert_equal ActionDispatch.test_app, app + end + end + RUBY + + with_rails_env("test") { rails("db:migrate") } + output = rails("test") assert_match(/0 failures, 0 errors/, output) end end |