summaryrefslogtreecommitdiff
path: root/test/unit/couch_stream_test.rb
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2013-09-10 09:44:38 +0200
committerAzul <azul@riseup.net>2013-09-10 09:44:38 +0200
commit57140b80f00aab43918a3ec3276062823971dec7 (patch)
tree759de1356d0cee24e44a4229629ddaf2fc662ad0 /test/unit/couch_stream_test.rb
parentc221405796270f46d8d4881183fd55fd4d977da9 (diff)
bringing over couch_changes from leap_ca including tests
Diffstat (limited to 'test/unit/couch_stream_test.rb')
-rw-r--r--test/unit/couch_stream_test.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/couch_stream_test.rb b/test/unit/couch_stream_test.rb
new file mode 100644
index 0000000..48b663a
--- /dev/null
+++ b/test/unit/couch_stream_test.rb
@@ -0,0 +1,35 @@
+require File.expand_path('../../test_helper.rb', __FILE__)
+require 'tapicero/couch_stream'
+
+# we'll mock this
+module Yajl
+ class HttpStream
+ end
+end
+
+class CouchStreamTest < MiniTest::Unit::TestCase
+
+ def setup
+ @root = "http://server/database"
+ @stream = Tapicero::CouchStream.new(@root)
+ @url = @root + "/_changes?a=b&c=d"
+ @path = "_changes"
+ @options = {:a => :b, :c => :d}
+ end
+
+ def test_get
+ Yajl::HttpStream.expects(:get).
+ with(@url, :symbolize_keys => true).
+ yields(stub_hash = stub)
+ @stream.get(@path, @options) do |hash|
+ assert_equal stub_hash, hash
+ end
+ end
+
+ # internal
+ def test_url_creation
+ assert_equal "http://server/database/", @stream.send(:url_for, "")
+ assert_equal @url, @stream.send(:url_for, @path, @options)
+ end
+
+end