Sha256: 9fa317f874c45bae879dfba35167ac58004d285e68112d007117dfb949e8671a

Contents?: true

Size: 518 Bytes

Versions: 4

Compression:

Stored size: 518 Bytes

Contents

module CypressRails
  class ConfiguresTestServer
    def call(port: ENV["RAILS_CYPRESS_PORT"])
      require "capybara"
      require "selenium-webdriver"
      Capybara.server_port = port || find_available_port
      Capybara.always_include_port = true
      Capybara.server = :puma, {Silent: false}
      Capybara.current_session

      true
    end

    private

    def find_available_port
      server = TCPServer.new(Capybara.server_host, 0)
      server.addr[1]
    ensure
      server&.close
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cypress-rails-0.0.4 lib/cypress-rails/configures_test_server.rb
cypress-rails-0.0.3 lib/cypress-rails/configures_test_server.rb
cypress-rails-0.0.2 lib/cypress-rails/configures_test_server.rb
cypress-rails-0.0.1 lib/cypress-rails/configures_test_server.rb