lib/parklife/browser.rb in parklife-0.4.0 vs lib/parklife/browser.rb in parklife-0.5.0

- old
+ new

@@ -1,22 +1,30 @@ +# frozen_string_literal: true + +require 'parklife/utils' require 'rack/test' module Parklife class Browser attr_reader :app, :base, :env, :session def initialize(app, base) @app = app @base = base - @env = { - 'HTTP_HOST' => base.host, - 'HTTPS' => base.scheme == 'https' ? 'on' : 'off', - script_name: base.path.chomp('/'), - } @session = Rack::Test::Session.new(app) + set_env end def get(path) session.get(path, nil, env) end + + private + def set_env + @env = { + 'HTTP_HOST' => Utils.host_with_port(base), + 'HTTPS' => base.scheme == 'https' ? 'on' : 'off', + script_name: base.path.chomp('/'), + } + end end end