aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/system_testing/server.rb
blob: 89ca6944d93252f1580d7964345862b9681586b3 (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
require "rack/handler/puma"

module ActionDispatch
  module SystemTesting
    class Server # :nodoc:
      class << self
        attr_accessor :silence_puma
      end

      self.silence_puma = false

      def run
        register
        setup
      end

      private
        def register
          Capybara.register_server :rails_puma do |app, port, host|
            Rack::Handler::Puma.run(
              app,
              Port: port,
              Threads: "0:1",
              Silent: self.class.silence_puma
            )
          end
        end

        def setup
          set_server
          set_port
        end

        def set_server
          Capybara.server = :rails_puma
        end

        def set_port
          Capybara.always_include_port = true
        end
    end
  end
end