aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/system_test_case_test.rb
blob: d15a0d9210b047930c081e4226326fc8393e8577 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# frozen_string_literal: true

require "isolation/abstract_unit"
require "rack/test"

class SystemTestCaseTest < ActiveSupport::TestCase
  include ActiveSupport::Testing::Isolation

  def setup
    build_app
  end

  def teardown
    teardown_app
  end

  test "url helpers are delegated to a proxy class" do
    app_file "config/routes.rb", <<-RUBY
      Rails.application.routes.draw do
        get 'foo', to: 'foo#index', as: 'test_foo'
      end
    RUBY

    app("test")

    assert_not_includes(ActionDispatch::SystemTestCase.runnable_methods, :test_foo_url)
  end

  test "system tests set the Capybara host in the url_options by default" do
    app_file "config/routes.rb", <<-RUBY
      Rails.application.routes.draw do
        get 'foo', to: 'foo#index', as: 'test_foo'
      end
    RUBY

    app("test")
    system_test = ActionDispatch::SystemTestCase.new("my_test")
    previous_app_host = ::Capybara.app_host
    ::Capybara.app_host = "https://my_test_example.com"

    assert_equal("https://my_test_example.com/foo", system_test.test_foo_url)
  ensure
    ::Capybara.app_host = previous_app_host
  end
end