Skip to content

Commit

Permalink
Add Cursor spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed Oct 17, 2011
1 parent 5dbd857 commit 4f47075
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/twitter/cursor.rb
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions 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

0 comments on commit 4f47075

Please sign in to comment.