Added code improvements to request handling for merb, thanks to David Leal

This commit is contained in:
Rob Kaufman 2008-10-22 10:30:39 -07:00
parent ef0176f187
commit 190fe0b73f
2 changed files with 8 additions and 33 deletions

View File

@ -20,27 +20,15 @@ lib/webrat/core/select_option.rb
lib/webrat/core/session.rb
lib/webrat/mechanize.rb
lib/webrat/mechanize/mechanize_session.rb
lib/webrat/merb.rb
lib/webrat/merb/indifferent_access.rb
lib/webrat/merb/param_parser.rb
lib/webrat/merb/support.rb
lib/webrat/merb/url_encoded_pair_parser.rb
lib/webrat/rack/rack_session.rb
lib/webrat/rails.rb
lib/webrat/rails/rails_session.rb
lib/webrat/rails/redirect_actions.rb
lib/webrat/rails/session.rb
lib/webrat/selenium.rb
lib/webrat/selenium/selenium_session.rb
lib/webrat/selenium/location_strategy_javascript/button.js
lib/webrat/selenium/location_strategy_javascript/label.js
lib/webrat/selenium/location_strategy_javascript/webrat.js
lib/webrat/selenium/location_strategy_javascript/webratlink.js
lib/webrat/selenium/location_strategy_javascript/webratlinkwithin.js
lib/webrat/selenium/location_strategy_javascript/webratselectwithoption.js
lib/webrat/sinatra/sinatra_session.rb
mechanize_spike.rb
selenium_spike.rb
spec/api/attaches_file_spec.rb
spec/api/basic_auth_spec.rb
spec/api/checks_spec.rb
spec/api/chooses_spec.rb
spec/api/clicks_button_spec.rb
@ -61,6 +49,4 @@ spec/spec_helper.rb
spec/webrat/core/logging_spec.rb
spec/webrat/core/session_spec.rb
spec/webrat/rails/rails_session_spec.rb
spec/webrat/merb/helper.rb
spec/webrat/rails/helper.rb
webrat.gemspec
webrat.gemspec

View File

@ -1,5 +1,5 @@
module Webrat
class MerbSession < Session
class Session
include Merb::Test::RequestHelper
attr_reader :response
@ -25,24 +25,13 @@ module Webrat
end
def response_code
@response.code
@response.status
end
protected
def do_request(url, data, headers, method)
all = (headers || {})
all[:method] = method unless all[:method] || all["REQUEST_METHOD"]
unless data.empty?
if verb == "post"
all[:body_params] = data
elsif verb == "get"
all[:params] = data
end
end
@response = request(url, all)
@response = self.get(@response.headers['Location'], nil, @response.headers) if @response.status == 302
@response = request(url, :params => data, :headers => headers, :method => method)
self.get(@response.headers['Location'], nil, @response.headers) if @response.status == 302
end
end
@ -50,7 +39,7 @@ end
class Merb::Test::RspecStory
def browser
@browser ||= Webrat::MerbSession.new
@browser ||= Webrat::Session.new
end
end