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, current_fragment: nil) ⇒ ResponseProxy

Returns a new instance of ResponseProxy.



172
173
174
175
# File 'lib/capybara/mechanize/browser.rb', line 172

def initialize(page, current_fragment: nil)
  @page = page
  @current_fragment = current_fragment
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



170
171
172
# File 'lib/capybara/mechanize/browser.rb', line 170

def page
  @page
end

Instance Method Details

#[](key) ⇒ Object



190
191
192
# File 'lib/capybara/mechanize/browser.rb', line 190

def [](key)
  headers[key]
end

#current_urlObject



177
178
179
180
181
# File 'lib/capybara/mechanize/browser.rb', line 177

def current_url
  uri = page.uri.dup
  uri.fragment = @current_fragment if @current_fragment
  uri.to_s
end

#headersObject



183
184
185
186
187
188
# File 'lib/capybara/mechanize/browser.rb', line 183

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', '')
  headers
end

#redirect?Boolean

Returns:

  • (Boolean)


198
199
200
# File 'lib/capybara/mechanize/browser.rb', line 198

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

#statusObject



194
195
196
# File 'lib/capybara/mechanize/browser.rb', line 194

def status
  page.code.to_i
end