Cleanup session initializaton in Webrat::Methods

This commit is contained in:
Bryan Helmkamp 2009-08-12 21:55:12 -04:00
parent ec43bb9546
commit 66251b66ae
2 changed files with 10 additions and 8 deletions

View File

@ -16,11 +16,11 @@ module Webrat
end
def webrat_session
@_webrat_session ||= ::Webrat::Session.new(webrat_adapter)
end
def webrat_adapter
@_webrat_adapter ||= Webrat.adapter_class.new(self)
@_webrat_session ||= begin
session = Webrat.session_class.new
session.adapter = Webrat.adapter_class.new(self) if session.respond_to?(:adapter=)
session
end
end
# all of these methods delegate to the @session, which should

View File

@ -59,6 +59,9 @@ For example:
extend Forwardable
include Logging
include SaveAndOpenPage
attr_accessor :adapter
attr_reader :current_url
attr_reader :elements
@ -66,13 +69,12 @@ For example:
:response_body=, :response_code=,
:get, :post, :put, :delete
def initialize(adapter=nil)
def initialize(adapter = nil)
@adapter = adapter
@http_method = :get
@data = {}
@default_headers = {}
@custom_headers = {}
@adapter = adapter
reset
end