Compare commits

..

1 Commits

Author SHA1 Message Date
Damian Janowski 39183b031a Limit the amount of error pages open. 2010-04-23 18:57:11 -03:00
9 changed files with 43 additions and 32 deletions

View File

@ -1,4 +1,4 @@
== 0.7.1 / 2010-04-26
== 0.7.1
* Minor enhancements

View File

@ -2,7 +2,7 @@ require "rack"
require "nokogiri"
module Webrat
VERSION = "0.7.2.pre"
VERSION = "0.7.1.pre"
autoload :MechanizeAdapter, "webrat/adapters/mechanize"
autoload :MerbAdapter, "webrat/adapters/merb"

View File

@ -93,7 +93,7 @@ module Webrat
end
def open_error_files? #:nodoc:
@open_error_files ? true : false
!! @open_error_files
end
# Allows setting of webrat's mode, valid modes are:

View File

@ -110,7 +110,7 @@ module Webrat
when :rack, :sinatra
Rack::Utils.parse_nested_query(query_string)
else
Hash[query_string.split('&').map {|query| [ query.split('=').first, query.split('=').last ]}]
query_string.split('&').map {|query| { query.split('=').first => query.split('=').last }}
end
end

View File

@ -76,6 +76,7 @@ For example:
@default_headers = {}
@custom_headers = {}
@current_url = nil
@exceptions = 0
reset
end
@ -118,8 +119,7 @@ For example:
process_request(http_method, url, data, h)
save_and_open_page if exception_caught? && Webrat.configuration.open_error_files?
raise PageLoadError.new("Page load was not successful (Code: #{response_code.inspect}):\n#{formatted_error}") unless success_code?
process_response_errors
reset
@ -299,5 +299,14 @@ For example:
@_page_scope = nil
end
def process_response_errors
if exception_caught? && @exceptions < 3 && Webrat.configuration.open_error_files?
save_and_open_page
@exceptions += 1
end
raise PageLoadError.new("Page load was not successful (Code: #{response_code.inspect}):\n#{formatted_error}") unless success_code?
end
end
end

View File

@ -41,6 +41,10 @@ class RackApp < Sinatra::Base
uploaded_file = params[:uploaded_file]
Marshal.dump(:tempfile => uploaded_file[:tempfile].read, :type => uploaded_file[:type], :filename => uploaded_file[:filename])
end
get "/error" do
["Exception caught: you wanted it."]
end
end
__END__

View File

@ -58,6 +58,24 @@ class WebratRackTest < Test::Unit::TestCase
assert_equal "webrat_rack_test.rb", upload[:filename]
assert_equal File.read(__FILE__), upload[:tempfile]
end
def test_open_errors
$open_pages = []
Webrat.configure do |config|
config.open_error_files = true
end
def webrat_session.open_in_browser(path)
$open_pages << path
end
5.times do
visit "/error"
end
assert_equal 3, $open_pages.size
end
end
class WebratRackSetupTest < Test::Unit::TestCase

View File

@ -48,22 +48,4 @@ describe "Multiple nested params" do
webrat_session.should_receive(:post).with("/family", params)
click_button
end
it "should correctly construct a query string" do
Webrat.configuration.mode = :mechanize
with_html <<-HTML
<html>
<form method="get" action="/search">
<input type="text" name="query" value="my-query" />
<input type="submit" />
</form>
</html>
HTML
params = { "query" => "my-query" }
webrat_session.should_receive(:get).with("/search", params)
click_button
end
end

View File

@ -2,11 +2,11 @@
Gem::Specification.new do |s|
s.name = %q{webrat}
s.version = "0.7.2.pre"
s.version = "0.7.1.pre"
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Bryan Helmkamp"]
s.date = %q{2010-04-26}
s.date = %q{2010-01-17}
s.description = %q{Webrat lets you quickly write expressive and robust acceptance tests
for a Ruby web application. It supports simulating a browser inside
a Ruby process to avoid the performance hit and browser dependency of
@ -72,7 +72,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
"lib/webrat/core_extensions/deprecate.rb",
"lib/webrat/core_extensions/detect_mapped.rb",
"lib/webrat/core_extensions/meta_class.rb",
"lib/webrat/core_extensions/nil_to_query_string.rb",
"lib/webrat/core_extensions/nil_to_param.rb",
"lib/webrat/core_extensions/tcp_socket.rb",
"lib/webrat/integrations/merb.rb",
"lib/webrat/integrations/rails.rb",
@ -195,7 +195,6 @@ Most Ruby web frameworks and testing frameworks are supported.}
"spec/integration/sinatra/test/test_helper.rb",
"spec/private/core/configuration_spec.rb",
"spec/private/core/field_spec.rb",
"spec/private/core/form_spec.rb",
"spec/private/core/link_spec.rb",
"spec/private/core/session_spec.rb",
"spec/private/mechanize/mechanize_adapter_spec.rb",
@ -239,7 +238,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
s.homepage = %q{http://github.com/brynary/webrat}
s.require_paths = ["lib"]
s.rubyforge_project = %q{webrat}
s.rubygems_version = %q{1.3.6}
s.rubygems_version = %q{1.3.5}
s.summary = %q{Ruby Acceptance Testing for Web applications}
s.test_files = [
"spec/fakes/test_adapter.rb",
@ -294,7 +293,6 @@ Most Ruby web frameworks and testing frameworks are supported.}
"spec/integration/sinatra/test/test_helper.rb",
"spec/private/core/configuration_spec.rb",
"spec/private/core/field_spec.rb",
"spec/private/core/form_spec.rb",
"spec/private/core/link_spec.rb",
"spec/private/core/session_spec.rb",
"spec/private/mechanize/mechanize_adapter_spec.rb",