Skip to content

Commit

Permalink
Added method Twitter::SearchResults#next_results?
Browse files Browse the repository at this point in the history
Returns true if there is a next page for a Twitter SearchResult.
Returns false otherwise

Aliased to next_page? for backward compatibility with v1 API
  • Loading branch information
KentonWhite committed Mar 13, 2013
1 parent 68915e0 commit d951db4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/twitter/search_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def search_metadata?
def since_id
@attrs[:search_metadata][:since_id] if search_metadata?
end

# @return [Boolean]
def next_results?
!@attrs[:search_metadata][:next_results].nil? if search_metadata?
end
alias next_page? next_results?

end
end
15 changes: 15 additions & 0 deletions spec/twitter/search_results_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,20 @@
expect(since_id).to be_nil
end
end

describe "#next_results?" do
it "returns true when next_results is set" do
next_results = Twitter::SearchResults.new(:search_metadata => {:next_results => "?"}).next_results?
expect(next_results).to be_true
end
it "returns false when next_results is not set" do
next_results = Twitter::SearchResults.new(:search_metadata => {}).next_results?
expect(next_results).to be_false
end
it "returns false is search_metadata is not set" do
next_results = Twitter::SearchResults.new().next_results?
expect(next_results).to be_false
end
end

end

0 comments on commit d951db4

Please sign in to comment.