Skip to content

Commit

Permalink
Merge 368b2ff into d6c5100
Browse files Browse the repository at this point in the history
  • Loading branch information
dsalahutdinov committed Mar 25, 2018
2 parents d6c5100 + 368b2ff commit 90ff9d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/twitter/search_results.rb
Expand Up @@ -9,7 +9,7 @@ class SearchResults
include Twitter::Enumerable
include Twitter::Utils
# @return [Hash]
attr_reader :attrs
attr_reader :attrs, :rate_limit
alias to_h attrs
alias to_hash to_h

Expand Down Expand Up @@ -48,8 +48,9 @@ def next_page

# @return [Hash]
def fetch_next_page
response = Twitter::REST::Request.new(@client, @request_method, @path, @options.merge(next_page)).perform
self.attrs = response
response = Twitter::REST::Request.new(@client, @request_method, @path, @options.merge(next_page))
self.attrs = response.perform
@rate_limit = response.rate_limit
end

# @param attrs [Hash]
Expand Down
4 changes: 3 additions & 1 deletion spec/twitter/search_results_spec.rb
Expand Up @@ -14,8 +14,10 @@
end
it 'iterates' do
count = 0
@client.search('#freebandnames').each { count += 1 }
search_results= @client.search('#freebandnames')
search_results.each { count += 1 }
expect(count).to eq(6)
expect(search_results.rate_limit).to be_a(Twitter::RateLimit)
end
it 'passes through parameters to the next request' do
stub_get('/1.1/search/tweets.json').with(query: {q: '#freebandnames', since_id: '414071360078878542', count: '100'}).to_return(body: fixture('search.json'), headers: {content_type: 'application/json; charset=utf-8'})
Expand Down

0 comments on commit 90ff9d7

Please sign in to comment.