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.



142
143
144
# File 'lib/capybara/mechanize/browser.rb', line 142

def initialize(page)
  @page = page
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



140
141
142
# File 'lib/capybara/mechanize/browser.rb', line 140

def page
  @page
end

Instance Method Details

#[](key) ⇒ Object



157
158
159
# File 'lib/capybara/mechanize/browser.rb', line 157

def [](key)
  headers[key]
end

#current_urlObject



146
147
148
# File 'lib/capybara/mechanize/browser.rb', line 146

def current_url
  page.uri.to_s
end

#headersObject



150
151
152
153
154
155
# File 'lib/capybara/mechanize/browser.rb', line 150

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)


165
166
167
# File 'lib/capybara/mechanize/browser.rb', line 165

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

#statusObject



161
162
163
# File 'lib/capybara/mechanize/browser.rb', line 161

def status
  page.code.to_i
end