Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add Cursor spec

  • Loading branch information...
commit 4f47075d6b0ec313485085a2002f60f92fc6d538 1 parent 5dbd857
@sferik sferik authored
Showing with 44 additions and 1 deletion.
  1. +1 −1  lib/twitter/cursor.rb
  2. +43 −0 spec/twitter/cursor_spec.rb
View
2  lib/twitter/cursor.rb
@@ -14,7 +14,7 @@ def initialize(cursor, method, klass=nil)
else
item
end
- end
+ end unless cursor[method.to_s].nil?
@next_cursor = cursor['next_cursor']
@previous_cursor = cursor['previous_cursor']
singleton_class.class_eval do
View
43 spec/twitter/cursor_spec.rb
@@ -0,0 +1,43 @@
+require 'helper'
+
+describe Twitter::Cursor do
+
+ describe "#first?" do
+ context "when previous cursor equals zero" do
+ before do
+ @cursor = Twitter::Cursor.new({'previous_cursor' => 0}, 'ids')
+ end
+ it "should return true" do
+ @cursor.first?.should be_true
+ end
+ end
+ context "when previous cursor does not equal zero" do
+ before do
+ @cursor = Twitter::Cursor.new({'previous_cursor' => 1}, 'ids')
+ end
+ it "should return true" do
+ @cursor.first?.should be_false
+ end
+ end
+ end
+
+ describe "#last?" do
+ context "when next cursor equals zero" do
+ before do
+ @cursor = Twitter::Cursor.new({'next_cursor' => 0}, 'ids')
+ end
+ it "should return true" do
+ @cursor.last?.should be_true
+ end
+ end
+ context "when next cursor does not equal zero" do
+ before do
+ @cursor = Twitter::Cursor.new({'next_cursor' => 1}, 'ids')
+ end
+ it "should return false" do
+ @cursor.last?.should be_false
+ end
+ end
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.