Added code improvements to request handling for merb

This commit is contained in:
Rob Kaufman 2008-10-22 10:29:32 -07:00
parent 86879c13c0
commit ef0176f187
2 changed files with 33 additions and 8 deletions

View File

@ -20,15 +20,27 @@ lib/webrat/core/select_option.rb
lib/webrat/core/session.rb lib/webrat/core/session.rb
lib/webrat/mechanize.rb lib/webrat/mechanize.rb
lib/webrat/mechanize/mechanize_session.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.rb
lib/webrat/rails/rails_session.rb lib/webrat/rails/rails_session.rb
lib/webrat/rails/redirect_actions.rb lib/webrat/rails/redirect_actions.rb
lib/webrat/rails/session.rb lib/webrat/rails/session.rb
lib/webrat/selenium.rb lib/webrat/selenium.rb
lib/webrat/selenium/selenium_session.rb lib/webrat/selenium/selenium_session.rb
mechanize_spike.rb lib/webrat/selenium/location_strategy_javascript/button.js
selenium_spike.rb 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
spec/api/attaches_file_spec.rb spec/api/attaches_file_spec.rb
spec/api/basic_auth_spec.rb
spec/api/checks_spec.rb spec/api/checks_spec.rb
spec/api/chooses_spec.rb spec/api/chooses_spec.rb
spec/api/clicks_button_spec.rb spec/api/clicks_button_spec.rb
@ -49,4 +61,6 @@ spec/spec_helper.rb
spec/webrat/core/logging_spec.rb spec/webrat/core/logging_spec.rb
spec/webrat/core/session_spec.rb spec/webrat/core/session_spec.rb
spec/webrat/rails/rails_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 module Webrat
class Session class MerbSession < Session
include Merb::Test::RequestHelper include Merb::Test::RequestHelper
attr_reader :response attr_reader :response
@ -25,13 +25,24 @@ module Webrat
end end
def response_code def response_code
@response.status @response.code
end end
protected protected
def do_request(url, data, headers, method) def do_request(url, data, headers, method)
@response = request(url, :params => data, :headers => headers, :method => method) all = (headers || {})
self.get(@response.headers['Location'], nil, @response.headers) if @response.status == 302 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
end end
end end
@ -39,7 +50,7 @@ end
class Merb::Test::RspecStory class Merb::Test::RspecStory
def browser def browser
@browser ||= Webrat::Session.new @browser ||= Webrat::MerbSession.new
end end
end end