Cleanup session initializaton in Webrat::Methods
This commit is contained in:
parent
ec43bb9546
commit
66251b66ae
@ -16,11 +16,11 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def webrat_session
|
def webrat_session
|
||||||
@_webrat_session ||= ::Webrat::Session.new(webrat_adapter)
|
@_webrat_session ||= begin
|
||||||
|
session = Webrat.session_class.new
|
||||||
|
session.adapter = Webrat.adapter_class.new(self) if session.respond_to?(:adapter=)
|
||||||
|
session
|
||||||
end
|
end
|
||||||
|
|
||||||
def webrat_adapter
|
|
||||||
@_webrat_adapter ||= Webrat.adapter_class.new(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# all of these methods delegate to the @session, which should
|
# all of these methods delegate to the @session, which should
|
||||||
|
@ -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
|
||||||
|
|
||||||
@ -67,12 +70,11 @@ For example:
|
|||||||
: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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user