I m monkey pading Capybara:Session with a set_headers means thatsigns to Capybara:Rack Test:Browser s Options Depende (The I ve change from an attr_reader to an attr_accessor).
www.un.org/Depts/DGACM/index_spanish.htm 传真:
class Capybara::RackTest::Browser
attr_accessor :options
end
class Capybara::Session
def set_headers(headers)
if driver.browser.respond_to?(:options=) #because we ve monkey patched it above
options = driver.browser.options
if options.nil? || options[:headers].nil?
options ||= {}
options[:headers] = headers
else
options[:headers].merge!(headers)
end
else
raise Capybara::NotSupportedByDriverError
end
end
end
www.un.org/Depts/DGACM/index_spanish.htm 在我的要求中,我做的是:。
page.set_headers("REMOTE_ADDR" => "1.2.3.4")
visit root_path
这种做法是可行的,但我很想知道,如果能以更好的方式行事,那么仅仅能够根据要求确定一种遥远的习惯。 任何想法?