summaryrefslogtreecommitdiff
path: root/tests/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/helpers')
-rw-r--r--tests/helpers/couchdb_helper.rb1
-rw-r--r--tests/helpers/http_helper.rb5
2 files changed, 4 insertions, 2 deletions
diff --git a/tests/helpers/couchdb_helper.rb b/tests/helpers/couchdb_helper.rb
index d4d3c0e0..312e38ac 100644
--- a/tests/helpers/couchdb_helper.rb
+++ b/tests/helpers/couchdb_helper.rb
@@ -66,6 +66,7 @@ class LeapTest
# port: 5984
#
def couchdb_url_via_localhost(path="", options=nil)
+ path = path.gsub('"', '%22')
port = (options && options[:port]) || assert_property('couch.port')
if options && options[:username]
password = property("couch.users.%{username}.password" % options)
diff --git a/tests/helpers/http_helper.rb b/tests/helpers/http_helper.rb
index 0b13b754..2fcdc910 100644
--- a/tests/helpers/http_helper.rb
+++ b/tests/helpers/http_helper.rb
@@ -87,12 +87,13 @@ class LeapTest
options ||= {}
error_msg = options[:error_msg] || (url.respond_to?(:memo) ? url.memo : nil)
http_send(method, url, params, options) do |body, response, error|
- if body && response && response.code.to_i >= 200 && response.code.to_i < 300
+ ok = response && response.code.to_i >= 200 && response.code.to_i < 300
+ if body && ok
if block
yield(body) if block.arity == 1
yield(response, body) if block.arity == 2
end
- elsif response
+ elsif response && !ok
fail ["Expected a 200 status code from #{method} #{url}, but got #{response.code} instead.", error_msg, body].compact.join("\n")
else
fail ["Expected a response from #{method} #{url}, but got \"#{error}\" instead.", error_msg, body].compact.join("\n"), error