summaryrefslogtreecommitdiff
path: root/test/test_helper.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-05-15 22:03:08 -0700
committerelijah <elijah@riseup.net>2013-05-15 22:03:08 -0700
commit51dc03481a9be5148f16e8022a1b00b658739ff3 (patch)
treee370f488b6ce4b79c09778621d9f8fc2d95ee88d /test/test_helper.rb
parentb078659defeead5b68ca2f387d0e308fa7511eb4 (diff)
add CouchDB support.
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r--test/test_helper.rb14
1 files changed, 9 insertions, 5 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 757bcd1..187ee05 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -42,11 +42,15 @@ class MiniTest::Unit::TestCase
end
def stub_couch_response(uid, opts = {})
- options = {:status => 200, :body => ""}.merge(opts)
- url = ['http://', Nickserver::Config.couch_host, ':', Nickserver::Config.couch_port].join
- stub_http_request(:get, url).with(
- :query => {:address => uid}
- ).to_return(options)
+ # can't stub localhost, so set couch_host to anything else
+ Nickserver::Config.stub :couch_host, 'notlocalhost' do
+ uid = uid.split('@').first # TEMPORARY HACK FOR NOW. in the future
+ # the database should be able to be searchable by full address
+ options = {:status => 200, :body => ""}.merge(opts)
+ query = "\?key=#{"%22#{uid}%22"}&reduce=false"
+ stub_http_request(:get, /#{Regexp.escape(Nickserver::Couch::FetchKey.couch_url)}.*#{query}/).to_return(options)
+ yield
+ end
end
end