Class: Mechanize

Inherits:
Object
  • Object
show all
Defined in:
lib/mechanize_rspec/config.rb,
lib/mechanize_rspec/mechanize.rb

Defined Under Namespace

Modules: Config

Instance Method Summary collapse

Instance Method Details

#get(uri, parameters = [], referer = nil, headers = {}) ⇒ Object

Modyfikacja dotychczasowej metody get tak aby w tej chwili jeżeli jakiś link znajduje się na liście nastąpiło przekierowanie do pliku lokalnego



12
13
14
15
16
17
18
19
20
21
# File 'lib/mechanize_rspec/mechanize.rb', line 12

def get(uri, parameters = [], referer = nil, headers = {})
  return old_get(uri) if Config.dirname.nil?
  Config.push_uri(uri)
  return old_get(uri) if uri =~ /^(file:)/
  path = Config.location.select{|url, path| url =~ /#{Regexp.quote(uri)}?$/}.first.last
  path.nil? ? (raise "Not correct uri") : old_get(::File.join("file://#{Config.dirname}", path))
rescue
  Config.push_error_uri(uri)
  old_get("*#{uri}")
end

#old_getObject



7
# File 'lib/mechanize_rspec/mechanize.rb', line 7

alias :old_get :get