Class: Parklife::Browser
- Inherits:
-
Object
- Object
- Parklife::Browser
- Defined in:
- lib/parklife/browser.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #get(path, headers: nil) ⇒ Object
-
#initialize(app, base) ⇒ Browser
constructor
A new instance of Browser.
- #uri_for(path) ⇒ Object
Constructor Details
#initialize(app, base) ⇒ Browser
Returns a new instance of Browser.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/parklife/browser.rb', line 10 def initialize(app, base) @app = app @base = base @session = Rack::Test::Session.new(app) @env = { 'HTTP_HOST' => Utils.host_with_port(base), 'HTTPS' => base.scheme == 'https' ? 'on' : 'off', script_name: base.path.chomp('/'), } end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
8 9 10 |
# File 'lib/parklife/browser.rb', line 8 def app @app end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
8 9 10 |
# File 'lib/parklife/browser.rb', line 8 def base @base end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
8 9 10 |
# File 'lib/parklife/browser.rb', line 8 def env @env end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
8 9 10 |
# File 'lib/parklife/browser.rb', line 8 def session @session end |
Instance Method Details
#get(path, headers: nil) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/parklife/browser.rb', line 21 def get(path, headers: nil) session.get( path, nil, headers ? headers.merge(env) : env ) end |
#uri_for(path) ⇒ Object
29 30 31 |
# File 'lib/parklife/browser.rb', line 29 def uri_for(path) base.dup.tap { |uri| uri.path = path } end |