Added code improvements to request handling for merb, thanks to David Leal
This commit is contained in:
parent
ef0176f187
commit
190fe0b73f
20
Manifest.txt
20
Manifest.txt
@ -20,27 +20,15 @@ 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
|
||||||
lib/webrat/selenium/location_strategy_javascript/button.js
|
mechanize_spike.rb
|
||||||
lib/webrat/selenium/location_strategy_javascript/label.js
|
selenium_spike.rb
|
||||||
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
|
||||||
@ -61,6 +49,4 @@ 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
|
webrat.gemspec
|
||||||
spec/webrat/rails/helper.rb
|
|
||||||
webrat.gemspec
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
module Webrat
|
module Webrat
|
||||||
class MerbSession < Session
|
class Session
|
||||||
include Merb::Test::RequestHelper
|
include Merb::Test::RequestHelper
|
||||||
|
|
||||||
attr_reader :response
|
attr_reader :response
|
||||||
@ -25,24 +25,13 @@ module Webrat
|
|||||||
end
|
end
|
||||||
|
|
||||||
def response_code
|
def response_code
|
||||||
@response.code
|
@response.status
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def do_request(url, data, headers, method)
|
def do_request(url, data, headers, method)
|
||||||
all = (headers || {})
|
@response = request(url, :params => data, :headers => headers, :method => method)
|
||||||
all[:method] = method unless all[:method] || all["REQUEST_METHOD"]
|
self.get(@response.headers['Location'], nil, @response.headers) if @response.status == 302
|
||||||
|
|
||||||
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
|
||||||
@ -50,7 +39,7 @@ end
|
|||||||
|
|
||||||
class Merb::Test::RspecStory
|
class Merb::Test::RspecStory
|
||||||
def browser
|
def browser
|
||||||
@browser ||= Webrat::MerbSession.new
|
@browser ||= Webrat::Session.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user