Class: Capybara::Mechanize::Browser::ResponseProxy

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/capybara/mechanize/browser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page) ⇒ ResponseProxy

Returns a new instance of ResponseProxy.



266
267
268
# File 'lib/capybara/mechanize/browser.rb', line 266

def initialize(page)
  @page = page
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



264
265
266
# File 'lib/capybara/mechanize/browser.rb', line 264

def page
  @page
end

Instance Method Details

#current_urlObject



270
271
272
# File 'lib/capybara/mechanize/browser.rb', line 270

def current_url
  page.uri.to_s
end

#headersObject



274
275
276
277
278
279
# File 'lib/capybara/mechanize/browser.rb', line 274

def headers
  # Hax the content-type contains utf8, so Capybara specs are failing, need to ask mailinglist
  headers = page.response
  headers["content-type"].gsub!(';charset=utf-8', '') if headers["content-type"]
  headers
end

#redirect?Boolean

Returns:

  • (Boolean)


285
286
287
# File 'lib/capybara/mechanize/browser.rb', line 285

def redirect?
  status >= 300 && status < 400
end

#statusObject



281
282
283
# File 'lib/capybara/mechanize/browser.rb', line 281

def status
  page.code.to_i
end