summaryrefslogtreecommitdiff
path: root/test/unit/couch_changes_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_changes_test.rb
parentc221405796270f46d8d4881183fd55fd4d977da9 (diff)
bringing over couch_changes from leap_ca including tests
Diffstat (limited to 'test/unit/couch_changes_test.rb')
-rw-r--r--test/unit/couch_changes_test.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/unit/couch_changes_test.rb b/test/unit/couch_changes_test.rb
new file mode 100644
index 0000000..043caf1
--- /dev/null
+++ b/test/unit/couch_changes_test.rb
@@ -0,0 +1,32 @@
+require File.expand_path('../../test_helper.rb', __FILE__)
+require 'tapicero/couch_changes'
+
+class CouchChangesTest < MiniTest::Unit::TestCase
+
+ LAST_SEQ = 12
+
+ def setup
+ @stream = mock()
+ @changes = Tapicero::CouchChanges.new(@stream)
+ end
+
+ def test_last_seq
+ @stream.expects(:get).
+ with('_changes', {:limit => 1, :descending => true}).
+ yields(:last_seq => LAST_SEQ)
+ assert_equal LAST_SEQ, @changes.last_seq
+ end
+
+ def test_follow
+ stub_entry = {:new => :result}
+ @stream.expects(:get).
+ with('_changes', {:limit => 1, :descending => true}).
+ yields(:last_seq => LAST_SEQ)
+ @stream.expects(:get).
+ with('_changes', {:feed => :continuous, :since => LAST_SEQ}).
+ yields(stub_entry)
+ @changes.follow do |hash|
+ assert_equal stub_entry, hash
+ end
+ end
+end