File: suggested_users_spec.rb

package info (click to toggle)
ruby-twitter 7.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,840 kB
  • sloc: ruby: 10,919; makefile: 6
file content (57 lines) | stat: -rw-r--r-- 2,464 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'helper'

describe Twitter::REST::SuggestedUsers do
  before do
    @client = Twitter::REST::Client.new(consumer_key: 'CK', consumer_secret: 'CS', access_token: 'AT', access_token_secret: 'AS')
  end

  describe '#suggestions' do
    context 'with a category slug passed' do
      before do
        stub_get('/1.1/users/suggestions/art-design.json').to_return(body: fixture('category.json'), headers: {content_type: 'application/json; charset=utf-8'})
      end
      it 'requests the correct resource' do
        @client.suggestions('art-design')
        expect(a_get('/1.1/users/suggestions/art-design.json')).to have_been_made
      end
      it 'returns the users in a given category of the Twitter suggested user list' do
        suggestion = @client.suggestions('art-design')
        expect(suggestion).to be_a Twitter::Suggestion
        expect(suggestion.name).to eq('Art & Design')
        expect(suggestion.users).to be_an Array
        expect(suggestion.users.first).to be_a Twitter::User
      end
    end
    context 'without arguments passed' do
      before do
        stub_get('/1.1/users/suggestions.json').to_return(body: fixture('suggestions.json'), headers: {content_type: 'application/json; charset=utf-8'})
      end
      it 'requests the correct resource' do
        @client.suggestions
        expect(a_get('/1.1/users/suggestions.json')).to have_been_made
      end
      it 'returns the list of suggested user categories' do
        suggestions = @client.suggestions
        expect(suggestions).to be_an Array
        expect(suggestions.first).to be_a Twitter::Suggestion
        expect(suggestions.first.name).to eq('Art & Design')
      end
    end
  end

  describe '#suggest_users' do
    before do
      stub_get('/1.1/users/suggestions/art-design/members.json').to_return(body: fixture('members.json'), headers: {content_type: 'application/json; charset=utf-8'})
    end
    it 'requests the correct resource' do
      @client.suggest_users('art-design')
      expect(a_get('/1.1/users/suggestions/art-design/members.json')).to have_been_made
    end
    it 'returns users in a given category of the Twitter suggested user list and return their most recent status if they are not a protected user' do
      suggest_users = @client.suggest_users('art-design')
      expect(suggest_users).to be_an Array
      expect(suggest_users.first).to be_a Twitter::User
      expect(suggest_users.first.id).to eq(13)
    end
  end
end