Skip to content

Commit

Permalink
Cleanup session initializaton in Webrat::Methods
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Aug 13, 2009
1 parent ec43bb9 commit 66251b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/webrat/core/methods.rb
Expand Up @@ -16,11 +16,11 @@ def 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
Expand Down
8 changes: 5 additions & 3 deletions lib/webrat/core/session.rb
Expand Up @@ -59,20 +59,22 @@ class Session
extend Forwardable
include Logging
include SaveAndOpenPage

attr_accessor :adapter

attr_reader :current_url
attr_reader :elements

def_delegators :@adapter, :response, :response_code, :response_body,
: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

Expand Down

0 comments on commit 66251b6

Please sign in to comment.