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 end
def webrat_session def webrat_session
@_webrat_session ||= ::Webrat::Session.new(webrat_adapter) @_webrat_session ||= begin
end session = Webrat.session_class.new
session.adapter = Webrat.adapter_class.new(self) if session.respond_to?(:adapter=)
def webrat_adapter session
@_webrat_adapter ||= Webrat.adapter_class.new(self) end
end end
# all of these methods delegate to the @session, which should # all of these methods delegate to the @session, which should

View File

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