twitter 5.0.0 → 5.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. data/.yardopts +4 -0
  2. data/CHANGELOG.md +47 -0
  3. data/CONTRIBUTING.md +5 -5
  4. data/README.md +57 -56
  5. data/Rakefile +26 -5
  6. data/lib/twitter/arguments.rb +1 -2
  7. data/lib/twitter/base.rb +15 -18
  8. data/lib/twitter/basic_user.rb +3 -3
  9. data/lib/twitter/client.rb +9 -10
  10. data/lib/twitter/configuration.rb +5 -5
  11. data/lib/twitter/creatable.rb +0 -1
  12. data/lib/twitter/cursor.rb +9 -36
  13. data/lib/twitter/direct_message.rb +1 -1
  14. data/lib/twitter/entity/uri.rb +2 -2
  15. data/lib/twitter/enumerable.rb +10 -1
  16. data/lib/twitter/error/already_favorited.rb +1 -1
  17. data/lib/twitter/error/already_posted.rb +1 -1
  18. data/lib/twitter/error/already_retweeted.rb +1 -1
  19. data/lib/twitter/error/too_many_requests.rb +2 -2
  20. data/lib/twitter/error.rb +6 -6
  21. data/lib/twitter/factory.rb +2 -6
  22. data/lib/twitter/geo/point.rb +3 -5
  23. data/lib/twitter/geo.rb +1 -1
  24. data/lib/twitter/geo_factory.rb +1 -5
  25. data/lib/twitter/geo_results.rb +5 -8
  26. data/lib/twitter/identity.rb +1 -2
  27. data/lib/twitter/list.rb +10 -11
  28. data/lib/twitter/media/photo.rb +1 -2
  29. data/lib/twitter/media_factory.rb +1 -5
  30. data/lib/twitter/null_object.rb +4 -6
  31. data/lib/twitter/oembed.rb +1 -1
  32. data/lib/twitter/place.rb +17 -6
  33. data/lib/twitter/profile_banner.rb +1 -3
  34. data/lib/twitter/rate_limit.rb +1 -3
  35. data/lib/twitter/relationship.rb +1 -2
  36. data/lib/twitter/rest/api/direct_messages.rb +15 -15
  37. data/lib/twitter/rest/api/favorites.rb +15 -15
  38. data/lib/twitter/rest/api/friends_and_followers.rb +37 -42
  39. data/lib/twitter/rest/api/help.rb +8 -9
  40. data/lib/twitter/rest/api/lists.rb +69 -69
  41. data/lib/twitter/rest/api/oauth.rb +3 -4
  42. data/lib/twitter/rest/api/places_and_geo.rb +9 -10
  43. data/lib/twitter/rest/api/saved_searches.rb +8 -8
  44. data/lib/twitter/rest/api/search.rb +10 -2
  45. data/lib/twitter/rest/api/spam_reporting.rb +1 -2
  46. data/lib/twitter/rest/api/suggested_users.rb +4 -5
  47. data/lib/twitter/rest/api/timelines.rb +17 -18
  48. data/lib/twitter/rest/api/trends.rb +10 -11
  49. data/lib/twitter/rest/api/tweets.rb +31 -20
  50. data/lib/twitter/rest/api/undocumented.rb +6 -7
  51. data/lib/twitter/rest/api/users.rb +53 -54
  52. data/lib/twitter/rest/api/utils.rb +28 -34
  53. data/lib/twitter/rest/client.rb +8 -9
  54. data/lib/twitter/rest/request/multipart_with_file.rb +7 -5
  55. data/lib/twitter/rest/response/parse_error_json.rb +0 -2
  56. data/lib/twitter/rest/response/parse_json.rb +2 -2
  57. data/lib/twitter/rest/response/raise_error.rb +1 -3
  58. data/lib/twitter/search_results.rb +38 -56
  59. data/lib/twitter/settings.rb +2 -2
  60. data/lib/twitter/size.rb +2 -2
  61. data/lib/twitter/source_user.rb +1 -1
  62. data/lib/twitter/streaming/client.rb +69 -18
  63. data/lib/twitter/streaming/connection.rb +1 -3
  64. data/lib/twitter/streaming/deleted_tweet.rb +8 -0
  65. data/lib/twitter/streaming/event.rb +8 -8
  66. data/lib/twitter/streaming/friend_list.rb +2 -9
  67. data/lib/twitter/streaming/message_parser.rb +13 -3
  68. data/lib/twitter/streaming/response.rb +0 -2
  69. data/lib/twitter/streaming/stall_warning.rb +7 -0
  70. data/lib/twitter/suggestion.rb +0 -1
  71. data/lib/twitter/token.rb +2 -3
  72. data/lib/twitter/trend_results.rb +5 -8
  73. data/lib/twitter/tweet.rb +17 -18
  74. data/lib/twitter/user.rb +33 -35
  75. data/lib/twitter/utils.rb +14 -0
  76. data/lib/twitter/version.rb +2 -5
  77. data/lib/twitter.rb +1 -1
  78. data/spec/fixtures/forbidden.json +1 -0
  79. data/spec/fixtures/search.json +1 -1
  80. data/spec/fixtures/search2.json +1 -0
  81. data/spec/fixtures/track_streaming_user.json +2 -1
  82. data/spec/helper.rb +6 -2
  83. data/spec/twitter/base_spec.rb +9 -9
  84. data/spec/twitter/basic_user_spec.rb +6 -6
  85. data/spec/twitter/configuration_spec.rb +4 -4
  86. data/spec/twitter/cursor_spec.rb +13 -51
  87. data/spec/twitter/direct_message_spec.rb +36 -36
  88. data/spec/twitter/entity/uri_spec.rb +29 -29
  89. data/spec/twitter/error_spec.rb +21 -21
  90. data/spec/twitter/geo/point_spec.rb +9 -9
  91. data/spec/twitter/geo/polygon_spec.rb +5 -5
  92. data/spec/twitter/geo_factory_spec.rb +7 -7
  93. data/spec/twitter/geo_results_spec.rb +11 -11
  94. data/spec/twitter/geo_spec.rb +5 -5
  95. data/spec/twitter/identifiable_spec.rb +9 -9
  96. data/spec/twitter/list_spec.rb +38 -38
  97. data/spec/twitter/media/photo_spec.rb +58 -58
  98. data/spec/twitter/media_factory_spec.rb +5 -5
  99. data/spec/twitter/null_object_spec.rb +6 -6
  100. data/spec/twitter/oembed_spec.rb +68 -68
  101. data/spec/twitter/place_spec.rb +91 -62
  102. data/spec/twitter/profile_banner_spec.rb +3 -3
  103. data/spec/twitter/rate_limit_spec.rb +18 -18
  104. data/spec/twitter/relationship_spec.rb +16 -16
  105. data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
  106. data/spec/twitter/rest/api/favorites_spec.rb +93 -93
  107. data/spec/twitter/rest/api/friends_and_followers_spec.rb +357 -349
  108. data/spec/twitter/rest/api/geo_spec.rb +33 -33
  109. data/spec/twitter/rest/api/help_spec.rb +24 -24
  110. data/spec/twitter/rest/api/lists_spec.rb +487 -487
  111. data/spec/twitter/rest/api/oauth_spec.rb +30 -30
  112. data/spec/twitter/rest/api/saved_searches_spec.rb +50 -40
  113. data/spec/twitter/rest/api/search_spec.rb +27 -26
  114. data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
  115. data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
  116. data/spec/twitter/rest/api/timelines_spec.rb +58 -58
  117. data/spec/twitter/rest/api/trends_spec.rb +26 -26
  118. data/spec/twitter/rest/api/tweets_spec.rb +304 -266
  119. data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
  120. data/spec/twitter/rest/api/users_spec.rb +360 -360
  121. data/spec/twitter/rest/client_spec.rb +99 -103
  122. data/spec/twitter/saved_search_spec.rb +16 -16
  123. data/spec/twitter/search_results_spec.rb +14 -110
  124. data/spec/twitter/settings_spec.rb +8 -8
  125. data/spec/twitter/size_spec.rb +5 -5
  126. data/spec/twitter/source_user_spec.rb +6 -6
  127. data/spec/twitter/streaming/client_spec.rb +85 -54
  128. data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
  129. data/spec/twitter/streaming/event_spec.rb +20 -22
  130. data/spec/twitter/streaming/friend_list_spec.rb +11 -0
  131. data/spec/twitter/streaming/message_parser_spec.rb +54 -0
  132. data/spec/twitter/suggestion_spec.rb +11 -11
  133. data/spec/twitter/target_user_spec.rb +6 -6
  134. data/spec/twitter/token_spec.rb +4 -4
  135. data/spec/twitter/trend_results_spec.rb +30 -30
  136. data/spec/twitter/trend_spec.rb +21 -21
  137. data/spec/twitter/tweet_spec.rb +178 -164
  138. data/spec/twitter/user_spec.rb +190 -190
  139. data/twitter.gemspec +6 -6
  140. data.tar.gz.sig +0 -0
  141. metadata +44 -16
  142. metadata.gz.sig +0 -0
  143. data/lib/twitter/core_ext/enumerable.rb +0 -10
  144. data/lib/twitter/core_ext/kernel.rb +0 -10
  145. data/spec/twitter_spec.rb +0 -0
@@ -3,64 +3,64 @@ require 'helper'
3
3
  describe Twitter::REST::API::OAuth do
4
4
 
5
5
  before do
6
- @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS")
6
+ @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS')
7
7
  end
8
8
 
9
- describe "#token" do
9
+ describe '#token' do
10
10
  before do
11
11
  # WebMock treats Basic Auth differently so we have to chack against the full URL with credentials.
12
- @oauth2_token_url = "https://CK:CS@api.twitter.com/oauth2/token"
13
- stub_request(:post, @oauth2_token_url).with(:body => "grant_type=client_credentials").to_return(:body => fixture("bearer_token.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
+ @oauth2_token_url = 'https://CK:CS@api.twitter.com/oauth2/token'
13
+ stub_request(:post, @oauth2_token_url).with(:body => 'grant_type=client_credentials').to_return(:body => fixture('bearer_token.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
14
14
  end
15
- it "requests the correct resource" do
15
+ it 'requests the correct resource' do
16
16
  @client.token
17
- expect(a_request(:post, @oauth2_token_url).with(:body => {:grant_type => "client_credentials"})).to have_been_made
17
+ expect(a_request(:post, @oauth2_token_url).with(:body => {:grant_type => 'client_credentials'})).to have_been_made
18
18
  end
19
- it "requests with the correct headers" do
19
+ it 'requests with the correct headers' do
20
20
  @client.token
21
- expect(a_request(:post, @oauth2_token_url).with(:headers => {:content_type => "application/x-www-form-urlencoded; charset=UTF-8", :accept => "*/*"})).to have_been_made
21
+ expect(a_request(:post, @oauth2_token_url).with(:headers => {:content_type => 'application/x-www-form-urlencoded; charset=UTF-8', :accept => '*/*'})).to have_been_made
22
22
  end
23
- it "returns the bearer token" do
23
+ it 'returns the bearer token' do
24
24
  bearer_token = @client.token
25
- expect(bearer_token.access_token).to eq("AAAA%2FAAA%3DAAAAAAAA")
26
- expect(bearer_token.token_type).to eq("bearer")
25
+ expect(bearer_token.access_token).to eq('AAAA%2FAAA%3DAAAAAAAA')
26
+ expect(bearer_token.token_type).to eq('bearer')
27
27
  end
28
28
  end
29
29
 
30
- describe "#invalidate_token" do
30
+ describe '#invalidate_token' do
31
31
  before do
32
- stub_post("/oauth2/invalidate_token").with(:body => {:access_token => "AAAA%2FAAA%3DAAAAAAAA"}).to_return(:body => '{"access_token" : "AAAA%2FAAA%3DAAAAAAAA"}', :headers => {:content_type => "application/json; charset=utf-8"})
33
- @client.bearer_token = "AAAA%2FAAA%3DAAAAAAAA"
32
+ stub_post('/oauth2/invalidate_token').with(:body => {:access_token => 'AAAA%2FAAA%3DAAAAAAAA'}).to_return(:body => '{"access_token":"AAAA%2FAAA%3DAAAAAAAA"}', :headers => {:content_type => 'application/json; charset=utf-8'})
33
+ @client.bearer_token = 'AAAA%2FAAA%3DAAAAAAAA'
34
34
  end
35
- it "requests the correct resource" do
36
- @client.invalidate_token("AAAA%2FAAA%3DAAAAAAAA")
37
- expect(a_post("/oauth2/invalidate_token").with(:body => {:access_token => "AAAA%2FAAA%3DAAAAAAAA"})).to have_been_made
35
+ it 'requests the correct resource' do
36
+ @client.invalidate_token('AAAA%2FAAA%3DAAAAAAAA')
37
+ expect(a_post('/oauth2/invalidate_token').with(:body => {:access_token => 'AAAA%2FAAA%3DAAAAAAAA'})).to have_been_made
38
38
  end
39
- it "returns the invalidated token" do
40
- token = @client.invalidate_token("AAAA%2FAAA%3DAAAAAAAA")
41
- expect(token.access_token).to eq("AAAA%2FAAA%3DAAAAAAAA")
39
+ it 'returns the invalidated token' do
40
+ token = @client.invalidate_token('AAAA%2FAAA%3DAAAAAAAA')
41
+ expect(token.access_token).to eq('AAAA%2FAAA%3DAAAAAAAA')
42
42
  expect(token.token_type).to be_nil
43
43
  end
44
- context "with a token" do
45
- it "requests the correct resource" do
46
- token = Twitter::Token.new(:access_token => "AAAA%2FAAA%3DAAAAAAAA")
44
+ context 'with a token' do
45
+ it 'requests the correct resource' do
46
+ token = Twitter::Token.new(:access_token => 'AAAA%2FAAA%3DAAAAAAAA')
47
47
  @client.invalidate_token(token)
48
- expect(a_post("/oauth2/invalidate_token").with(:body => {:access_token => "AAAA%2FAAA%3DAAAAAAAA"})).to have_been_made
48
+ expect(a_post('/oauth2/invalidate_token').with(:body => {:access_token => 'AAAA%2FAAA%3DAAAAAAAA'})).to have_been_made
49
49
  end
50
50
  end
51
51
  end
52
52
 
53
- describe "#reverse_token" do
53
+ describe '#reverse_token' do
54
54
  before do
55
55
  # WebMock treats Basic Auth differently so we have to chack against the full URL with credentials.
56
- @oauth_request_token_url = "https://api.twitter.com/oauth/request_token?x_auth_mode=reverse_auth"
57
- stub_request(:post, @oauth_request_token_url).to_return(:body => fixture('request_token.txt'), :headers => {:content_type => "text/html; charset=utf-8"})
56
+ @oauth_request_token_url = 'https://api.twitter.com/oauth/request_token?x_auth_mode=reverse_auth'
57
+ stub_request(:post, @oauth_request_token_url).to_return(:body => fixture('request_token.txt'), :headers => {:content_type => 'text/html; charset=utf-8'})
58
58
  end
59
- it "requests the correct resource" do
59
+ it 'requests the correct resource' do
60
60
  @client.reverse_token
61
- expect(a_request(:post, @oauth_request_token_url).with(:params => {:x_auth_mode => "reverse_auth"})).to have_been_made
61
+ expect(a_request(:post, @oauth_request_token_url).with(:params => {:x_auth_mode => 'reverse_auth'})).to have_been_made
62
62
  end
63
- it "requests the correct resource" do
63
+ it 'requests the correct resource' do
64
64
  expect(@client.reverse_token).to eql fixture('request_token.txt').read
65
65
  end
66
66
  end
@@ -3,85 +3,95 @@ require 'helper'
3
3
  describe Twitter::REST::API::SavedSearches do
4
4
 
5
5
  before do
6
- @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
6
+ @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
7
7
  end
8
8
 
9
- describe "#saved_searches" do
10
- context "with ids passed" do
9
+ describe '#saved_searches' do
10
+ context 'with ids passed' do
11
11
  before do
12
- stub_get("/1.1/saved_searches/show/16129012.json").to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
+ stub_get('/1.1/saved_searches/show/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
13
+ stub_get('/1.1/saved_searches/show/16129013.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
13
14
  end
14
- it "requests the correct resource" do
15
- @client.saved_searches(16129012)
16
- expect(a_get("/1.1/saved_searches/show/16129012.json")).to have_been_made
15
+ it 'requests the correct resource' do
16
+ @client.saved_searches(16_129_012, 16_129_013)
17
+ expect(a_get('/1.1/saved_searches/show/16129012.json')).to have_been_made
18
+ expect(a_get('/1.1/saved_searches/show/16129013.json')).to have_been_made
17
19
  end
18
- it "returns an array of saved searches" do
19
- saved_searches = @client.saved_searches(16129012)
20
+ it 'returns an array of saved searches' do
21
+ saved_searches = @client.saved_searches(16_129_012, 16_129_013)
20
22
  expect(saved_searches).to be_an Array
23
+ expect(saved_searches.size).to eq(2)
21
24
  expect(saved_searches.first).to be_a Twitter::SavedSearch
22
- expect(saved_searches.first.name).to eq("twitter")
25
+ expect(saved_searches.first.name).to eq('twitter')
26
+ expect(saved_searches.last).to be_a Twitter::SavedSearch
27
+ expect(saved_searches.last.name).to eq('twitter')
23
28
  end
24
29
  end
25
- context "without ids passed" do
30
+ context 'without ids passed' do
26
31
  before do
27
- stub_get("/1.1/saved_searches/list.json").to_return(:body => fixture("saved_searches.json"), :headers => {:content_type => "application/json; charset=utf-8"})
32
+ stub_get('/1.1/saved_searches/list.json').to_return(:body => fixture('saved_searches.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
28
33
  end
29
- it "requests the correct resource" do
34
+ it 'requests the correct resource' do
30
35
  @client.saved_searches
31
- expect(a_get("/1.1/saved_searches/list.json")).to have_been_made
36
+ expect(a_get('/1.1/saved_searches/list.json')).to have_been_made
32
37
  end
33
- it "returns the authenticated user's saved search queries" do
38
+ it 'returns the saved search queries for the authenticated user' do
34
39
  saved_searches = @client.saved_searches
35
40
  expect(saved_searches).to be_an Array
36
41
  expect(saved_searches.first).to be_a Twitter::SavedSearch
37
- expect(saved_searches.first.name).to eq("twitter")
42
+ expect(saved_searches.first.name).to eq('twitter')
38
43
  end
39
44
  end
40
45
  end
41
46
 
42
- describe "#saved_search" do
47
+ describe '#saved_search' do
43
48
  before do
44
- stub_get("/1.1/saved_searches/show/16129012.json").to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
49
+ stub_get('/1.1/saved_searches/show/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
45
50
  end
46
- it "requests the correct resource" do
47
- @client.saved_search(16129012)
48
- expect(a_get("/1.1/saved_searches/show/16129012.json")).to have_been_made
51
+ it 'requests the correct resource' do
52
+ @client.saved_search(16_129_012)
53
+ expect(a_get('/1.1/saved_searches/show/16129012.json')).to have_been_made
49
54
  end
50
- it "returns a saved search" do
51
- saved_search = @client.saved_search(16129012)
55
+ it 'returns a saved search' do
56
+ saved_search = @client.saved_search(16_129_012)
52
57
  expect(saved_search).to be_a Twitter::SavedSearch
53
- expect(saved_search.name).to eq("twitter")
58
+ expect(saved_search.name).to eq('twitter')
54
59
  end
55
60
  end
56
61
 
57
- describe "#create_saved_search" do
62
+ describe '#create_saved_search' do
58
63
  before do
59
- stub_post("/1.1/saved_searches/create.json").with(:body => {:query => "twitter"}).to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
64
+ stub_post('/1.1/saved_searches/create.json').with(:body => {:query => 'twitter'}).to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
60
65
  end
61
- it "requests the correct resource" do
62
- @client.create_saved_search("twitter")
63
- expect(a_post("/1.1/saved_searches/create.json").with(:body => {:query => "twitter"})).to have_been_made
66
+ it 'requests the correct resource' do
67
+ @client.create_saved_search('twitter')
68
+ expect(a_post('/1.1/saved_searches/create.json').with(:body => {:query => 'twitter'})).to have_been_made
64
69
  end
65
- it "returns the created saved search" do
66
- saved_search = @client.create_saved_search("twitter")
70
+ it 'returns the created saved search' do
71
+ saved_search = @client.create_saved_search('twitter')
67
72
  expect(saved_search).to be_a Twitter::SavedSearch
68
- expect(saved_search.name).to eq("twitter")
73
+ expect(saved_search.name).to eq('twitter')
69
74
  end
70
75
  end
71
76
 
72
- describe "#destroy_saved_search" do
77
+ describe '#destroy_saved_search' do
73
78
  before do
74
- stub_post("/1.1/saved_searches/destroy/16129012.json").to_return(:body => fixture("saved_search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
79
+ stub_post('/1.1/saved_searches/destroy/16129012.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
80
+ stub_post('/1.1/saved_searches/destroy/16129013.json').to_return(:body => fixture('saved_search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
75
81
  end
76
- it "requests the correct resource" do
77
- @client.destroy_saved_search(16129012)
78
- expect(a_post("/1.1/saved_searches/destroy/16129012.json")).to have_been_made
82
+ it 'requests the correct resource' do
83
+ @client.destroy_saved_search(16_129_012, 16_129_013)
84
+ expect(a_post('/1.1/saved_searches/destroy/16129012.json')).to have_been_made
85
+ expect(a_post('/1.1/saved_searches/destroy/16129013.json')).to have_been_made
79
86
  end
80
- it "returns an array of deleted saved searches" do
81
- saved_searches = @client.destroy_saved_search(16129012)
87
+ it 'returns an array of deleted saved searches' do
88
+ saved_searches = @client.destroy_saved_search(16_129_012, 16_129_013)
82
89
  expect(saved_searches).to be_an Array
90
+ expect(saved_searches.size).to eq(2)
83
91
  expect(saved_searches.first).to be_a Twitter::SavedSearch
84
- expect(saved_searches.first.name).to eq("twitter")
92
+ expect(saved_searches.first.name).to eq('twitter')
93
+ expect(saved_searches.last).to be_a Twitter::SavedSearch
94
+ expect(saved_searches.last.name).to eq('twitter')
85
95
  end
86
96
  end
87
97
 
@@ -3,37 +3,38 @@ require 'helper'
3
3
  describe Twitter::REST::API::Search do
4
4
 
5
5
  before do
6
- @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
6
+ @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
7
7
  end
8
8
 
9
- describe "#search" do
10
- before do
11
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter"}).to_return(:body => fixture("search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
- end
13
- it "requests the correct resource" do
14
- @client.search("twitter")
15
- expect(a_get("/1.1/search/tweets.json").with(:query => {:q => "twitter"})).to have_been_made
16
- end
17
- it "returns recent Tweets related to a query with images and videos embedded" do
18
- search = @client.search("twitter")
19
- expect(search).to be_a Twitter::SearchResults
20
- expect(search.first).to be_a Twitter::Tweet
21
- expect(search.first.text).to eq("Bubble Mailer #freebandnames")
22
- end
23
- it "returns the max_id value for a search result" do
24
- search = @client.search("twitter")
25
- expect(search.max_id).to eq(250126199840518145)
9
+ describe '#search' do
10
+ context 'without count specified' do
11
+ before do
12
+ stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '100'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
13
+ end
14
+ it 'requests the correct resource' do
15
+ @client.search('#freebandnames')
16
+ expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '100'})).to have_been_made
17
+ end
18
+ it 'returns recent Tweets related to a query with images and videos embedded' do
19
+ search = @client.search('#freebandnames')
20
+ expect(search).to be_a Twitter::SearchResults
21
+ expect(search.first).to be_a Twitter::Tweet
22
+ expect(search.first.text).to eq('@Just_Reboot #FreeBandNames mono surround')
23
+ end
26
24
  end
27
-
28
- context "when search API responds a malformed result" do
25
+ context 'with count specified' do
29
26
  before do
30
- stub_get("/1.1/search/tweets.json").with(:query => {:q => "twitter"}).to_return(:body => fixture("search_malformed.json"), :headers => {:content_type => "application/json; charset=utf-8"})
27
+ stub_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3'}).to_return(:body => fixture('search.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
31
28
  end
32
-
33
- it "returns an empty array" do
34
- search = @client.search("twitter")
35
- expect(search.to_a).to be_an Array
36
- expect(search.to_a).to be_empty
29
+ it 'requests the correct resource' do
30
+ @client.search('#freebandnames', :count => 3)
31
+ expect(a_get('/1.1/search/tweets.json').with(:query => {:q => '#freebandnames', :count => '3'})).to have_been_made
32
+ end
33
+ it 'returns recent Tweets related to a query with images and videos embedded' do
34
+ search = @client.search('#freebandnames', :count => 3)
35
+ expect(search).to be_a Twitter::SearchResults
36
+ expect(search.first).to be_a Twitter::Tweet
37
+ expect(search.first.text).to eq('@Just_Reboot #FreeBandNames mono surround')
37
38
  end
38
39
  end
39
40
  end
@@ -3,22 +3,22 @@ require 'helper'
3
3
  describe Twitter::REST::API::SpamReporting do
4
4
 
5
5
  before do
6
- @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
6
+ @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
7
7
  end
8
8
 
9
- describe "#report_spam" do
9
+ describe '#report_spam' do
10
10
  before do
11
- stub_post("/1.1/users/report_spam.json").with(:body => {:screen_name => "sferik"}).to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
11
+ stub_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'}).to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
12
12
  end
13
- it "requests the correct resource" do
14
- @client.report_spam("sferik")
15
- expect(a_post("/1.1/users/report_spam.json").with(:body => {:screen_name => "sferik"})).to have_been_made
13
+ it 'requests the correct resource' do
14
+ @client.report_spam('sferik')
15
+ expect(a_post('/1.1/users/report_spam.json').with(:body => {:screen_name => 'sferik'})).to have_been_made
16
16
  end
17
- it "returns an array of users" do
18
- users = @client.report_spam("sferik")
17
+ it 'returns an array of users' do
18
+ users = @client.report_spam('sferik')
19
19
  expect(users).to be_an Array
20
20
  expect(users.first).to be_a Twitter::User
21
- expect(users.first.id).to eq(7505382)
21
+ expect(users.first.id).to eq(7_505_382)
22
22
  end
23
23
  end
24
24
 
@@ -3,53 +3,53 @@ require 'helper'
3
3
  describe Twitter::REST::API::SuggestedUsers do
4
4
 
5
5
  before do
6
- @client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
6
+ @client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
7
7
  end
8
8
 
9
- describe "#suggestions" do
10
- context "with a category slug passed" do
9
+ describe '#suggestions' do
10
+ context 'with a category slug passed' do
11
11
  before do
12
- stub_get("/1.1/users/suggestions/art-design.json").to_return(:body => fixture("category.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
+ stub_get('/1.1/users/suggestions/art-design.json').to_return(:body => fixture('category.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
13
13
  end
14
- it "requests the correct resource" do
15
- @client.suggestions("art-design")
16
- expect(a_get("/1.1/users/suggestions/art-design.json")).to have_been_made
14
+ it 'requests the correct resource' do
15
+ @client.suggestions('art-design')
16
+ expect(a_get('/1.1/users/suggestions/art-design.json')).to have_been_made
17
17
  end
18
- it "returns the users in a given category of the Twitter suggested user list" do
19
- suggestion = @client.suggestions("art-design")
18
+ it 'returns the users in a given category of the Twitter suggested user list' do
19
+ suggestion = @client.suggestions('art-design')
20
20
  expect(suggestion).to be_a Twitter::Suggestion
21
- expect(suggestion.name).to eq("Art & Design")
21
+ expect(suggestion.name).to eq('Art & Design')
22
22
  expect(suggestion.users).to be_an Array
23
23
  expect(suggestion.users.first).to be_a Twitter::User
24
24
  end
25
25
  end
26
- context "without arguments passed" do
26
+ context 'without arguments passed' do
27
27
  before do
28
- stub_get("/1.1/users/suggestions.json").to_return(:body => fixture("suggestions.json"), :headers => {:content_type => "application/json; charset=utf-8"})
28
+ stub_get('/1.1/users/suggestions.json').to_return(:body => fixture('suggestions.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
29
29
  end
30
- it "requests the correct resource" do
30
+ it 'requests the correct resource' do
31
31
  @client.suggestions
32
- expect(a_get("/1.1/users/suggestions.json")).to have_been_made
32
+ expect(a_get('/1.1/users/suggestions.json')).to have_been_made
33
33
  end
34
- it "returns the list of suggested user categories" do
34
+ it 'returns the list of suggested user categories' do
35
35
  suggestions = @client.suggestions
36
36
  expect(suggestions).to be_an Array
37
37
  expect(suggestions.first).to be_a Twitter::Suggestion
38
- expect(suggestions.first.name).to eq("Art & Design")
38
+ expect(suggestions.first.name).to eq('Art & Design')
39
39
  end
40
40
  end
41
41
  end
42
42
 
43
- describe "#suggest_users" do
43
+ describe '#suggest_users' do
44
44
  before do
45
- stub_get("/1.1/users/suggestions/art-design/members.json").to_return(:body => fixture("members.json"), :headers => {:content_type => "application/json; charset=utf-8"})
45
+ stub_get('/1.1/users/suggestions/art-design/members.json').to_return(:body => fixture('members.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
46
46
  end
47
- it "requests the correct resource" do
48
- @client.suggest_users("art-design")
49
- expect(a_get("/1.1/users/suggestions/art-design/members.json")).to have_been_made
47
+ it 'requests the correct resource' do
48
+ @client.suggest_users('art-design')
49
+ expect(a_get('/1.1/users/suggestions/art-design/members.json')).to have_been_made
50
50
  end
51
- 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
52
- suggest_users = @client.suggest_users("art-design")
51
+ 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
52
+ suggest_users = @client.suggest_users('art-design')
53
53
  expect(suggest_users).to be_an Array
54
54
  expect(suggest_users.first).to be_a Twitter::User
55
55
  expect(suggest_users.first.id).to eq(13)