diff --git a/lib/twitter/search_results.rb b/lib/twitter/search_results.rb index e2ad34131..02319be82 100644 --- a/lib/twitter/search_results.rb +++ b/lib/twitter/search_results.rb @@ -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 diff --git a/spec/twitter/search_results_spec.rb b/spec/twitter/search_results_spec.rb index 5ed3672f2..8c35f6f2a 100644 --- a/spec/twitter/search_results_spec.rb +++ b/spec/twitter/search_results_spec.rb @@ -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