twitter 5.1.1 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data.tar.gz.sig +0 -0
  2. data/.yardopts +2 -0
  3. data/CHANGELOG.md +10 -1
  4. data/CONTRIBUTING.md +2 -2
  5. data/README.md +30 -20
  6. data/Rakefile +26 -5
  7. data/lib/twitter/arguments.rb +0 -1
  8. data/lib/twitter/base.rb +13 -16
  9. data/lib/twitter/basic_user.rb +3 -3
  10. data/lib/twitter/client.rb +7 -8
  11. data/lib/twitter/configuration.rb +5 -5
  12. data/lib/twitter/core_ext/enumerable.rb +0 -2
  13. data/lib/twitter/core_ext/kernel.rb +0 -2
  14. data/lib/twitter/creatable.rb +0 -1
  15. data/lib/twitter/cursor.rb +7 -10
  16. data/lib/twitter/direct_message.rb +1 -1
  17. data/lib/twitter/entity/uri.rb +2 -2
  18. data/lib/twitter/enumerable.rb +1 -2
  19. data/lib/twitter/error.rb +4 -6
  20. data/lib/twitter/error/already_favorited.rb +1 -1
  21. data/lib/twitter/error/already_posted.rb +1 -1
  22. data/lib/twitter/error/already_retweeted.rb +1 -1
  23. data/lib/twitter/error/too_many_requests.rb +2 -2
  24. data/lib/twitter/factory.rb +2 -6
  25. data/lib/twitter/geo.rb +1 -1
  26. data/lib/twitter/geo/point.rb +3 -5
  27. data/lib/twitter/geo_factory.rb +1 -5
  28. data/lib/twitter/geo_results.rb +5 -8
  29. data/lib/twitter/identity.rb +1 -2
  30. data/lib/twitter/list.rb +4 -5
  31. data/lib/twitter/media/photo.rb +1 -2
  32. data/lib/twitter/media_factory.rb +1 -5
  33. data/lib/twitter/null_object.rb +4 -6
  34. data/lib/twitter/oembed.rb +1 -1
  35. data/lib/twitter/place.rb +4 -5
  36. data/lib/twitter/profile_banner.rb +1 -3
  37. data/lib/twitter/rate_limit.rb +1 -3
  38. data/lib/twitter/relationship.rb +1 -2
  39. data/lib/twitter/rest/api/direct_messages.rb +13 -14
  40. data/lib/twitter/rest/api/favorites.rb +10 -11
  41. data/lib/twitter/rest/api/friends_and_followers.rb +36 -36
  42. data/lib/twitter/rest/api/help.rb +8 -9
  43. data/lib/twitter/rest/api/lists.rb +62 -63
  44. data/lib/twitter/rest/api/oauth.rb +3 -4
  45. data/lib/twitter/rest/api/places_and_geo.rb +9 -10
  46. data/lib/twitter/rest/api/saved_searches.rb +5 -6
  47. data/lib/twitter/rest/api/search.rb +2 -3
  48. data/lib/twitter/rest/api/spam_reporting.rb +1 -2
  49. data/lib/twitter/rest/api/suggested_users.rb +4 -5
  50. data/lib/twitter/rest/api/timelines.rb +17 -18
  51. data/lib/twitter/rest/api/trends.rb +10 -11
  52. data/lib/twitter/rest/api/tweets.rb +15 -16
  53. data/lib/twitter/rest/api/undocumented.rb +6 -7
  54. data/lib/twitter/rest/api/users.rb +51 -52
  55. data/lib/twitter/rest/api/utils.rb +23 -30
  56. data/lib/twitter/rest/client.rb +8 -9
  57. data/lib/twitter/rest/request/multipart_with_file.rb +0 -1
  58. data/lib/twitter/rest/response/parse_error_json.rb +0 -2
  59. data/lib/twitter/rest/response/parse_json.rb +0 -2
  60. data/lib/twitter/rest/response/raise_error.rb +1 -3
  61. data/lib/twitter/search_results.rb +12 -15
  62. data/lib/twitter/settings.rb +2 -2
  63. data/lib/twitter/size.rb +2 -2
  64. data/lib/twitter/source_user.rb +1 -1
  65. data/lib/twitter/streaming/client.rb +71 -18
  66. data/lib/twitter/streaming/connection.rb +1 -3
  67. data/lib/twitter/streaming/deleted_tweet.rb +8 -0
  68. data/lib/twitter/streaming/event.rb +8 -8
  69. data/lib/twitter/streaming/friend_list.rb +2 -9
  70. data/lib/twitter/streaming/message_parser.rb +13 -7
  71. data/lib/twitter/streaming/response.rb +0 -2
  72. data/lib/twitter/streaming/stall_warning.rb +7 -0
  73. data/lib/twitter/suggestion.rb +0 -1
  74. data/lib/twitter/token.rb +2 -3
  75. data/lib/twitter/trend_results.rb +5 -8
  76. data/lib/twitter/tweet.rb +16 -24
  77. data/lib/twitter/user.rb +30 -32
  78. data/lib/twitter/version.rb +2 -5
  79. data/spec/fixtures/track_streaming_user.json +2 -1
  80. data/spec/helper.rb +6 -2
  81. data/spec/twitter/base_spec.rb +9 -9
  82. data/spec/twitter/basic_user_spec.rb +6 -6
  83. data/spec/twitter/configuration_spec.rb +4 -4
  84. data/spec/twitter/cursor_spec.rb +27 -27
  85. data/spec/twitter/direct_message_spec.rb +36 -36
  86. data/spec/twitter/entity/uri_spec.rb +27 -27
  87. data/spec/twitter/error_spec.rb +21 -21
  88. data/spec/twitter/geo/point_spec.rb +9 -9
  89. data/spec/twitter/geo/polygon_spec.rb +5 -5
  90. data/spec/twitter/geo_factory_spec.rb +7 -7
  91. data/spec/twitter/geo_results_spec.rb +11 -11
  92. data/spec/twitter/geo_spec.rb +5 -5
  93. data/spec/twitter/identifiable_spec.rb +9 -9
  94. data/spec/twitter/list_spec.rb +38 -38
  95. data/spec/twitter/media/photo_spec.rb +54 -54
  96. data/spec/twitter/media_factory_spec.rb +5 -5
  97. data/spec/twitter/null_object_spec.rb +6 -6
  98. data/spec/twitter/oembed_spec.rb +65 -65
  99. data/spec/twitter/place_spec.rb +89 -60
  100. data/spec/twitter/profile_banner_spec.rb +3 -3
  101. data/spec/twitter/rate_limit_spec.rb +18 -18
  102. data/spec/twitter/relationship_spec.rb +16 -16
  103. data/spec/twitter/rest/api/direct_messages_spec.rb +61 -61
  104. data/spec/twitter/rest/api/favorites_spec.rb +93 -93
  105. data/spec/twitter/rest/api/friends_and_followers_spec.rb +349 -349
  106. data/spec/twitter/rest/api/geo_spec.rb +33 -33
  107. data/spec/twitter/rest/api/help_spec.rb +24 -24
  108. data/spec/twitter/rest/api/lists_spec.rb +487 -487
  109. data/spec/twitter/rest/api/oauth_spec.rb +30 -30
  110. data/spec/twitter/rest/api/saved_searches_spec.rb +40 -40
  111. data/spec/twitter/rest/api/search_spec.rb +16 -16
  112. data/spec/twitter/rest/api/spam_reporting_spec.rb +9 -9
  113. data/spec/twitter/rest/api/suggested_users_spec.rb +23 -23
  114. data/spec/twitter/rest/api/timelines_spec.rb +58 -58
  115. data/spec/twitter/rest/api/trends_spec.rb +26 -26
  116. data/spec/twitter/rest/api/tweets_spec.rb +284 -284
  117. data/spec/twitter/rest/api/undocumented_spec.rb +51 -51
  118. data/spec/twitter/rest/api/users_spec.rb +360 -360
  119. data/spec/twitter/rest/client_spec.rb +99 -103
  120. data/spec/twitter/saved_search_spec.rb +16 -16
  121. data/spec/twitter/search_results_spec.rb +44 -44
  122. data/spec/twitter/settings_spec.rb +8 -8
  123. data/spec/twitter/size_spec.rb +5 -5
  124. data/spec/twitter/source_user_spec.rb +6 -6
  125. data/spec/twitter/streaming/client_spec.rb +53 -49
  126. data/spec/twitter/streaming/deleted_tweet_spec.rb +23 -0
  127. data/spec/twitter/streaming/event_spec.rb +20 -22
  128. data/spec/twitter/streaming/friend_list_spec.rb +11 -0
  129. data/spec/twitter/streaming/message_parser_spec.rb +54 -0
  130. data/spec/twitter/suggestion_spec.rb +11 -11
  131. data/spec/twitter/target_user_spec.rb +6 -6
  132. data/spec/twitter/token_spec.rb +4 -4
  133. data/spec/twitter/trend_results_spec.rb +30 -30
  134. data/spec/twitter/trend_spec.rb +20 -20
  135. data/spec/twitter/tweet_spec.rb +170 -173
  136. data/spec/twitter/user_spec.rb +179 -179
  137. data/twitter.gemspec +2 -2
  138. metadata +21 -4
  139. metadata.gz.sig +2 -1
@@ -3,191 +3,187 @@ require 'helper'
3
3
  describe Twitter::REST::Client 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 ".new" do
10
- context "when invalid credentials are provided" do
11
- it "raises a ConfigurationError exception" do
12
- expect {
13
- Twitter::REST::Client.new(:consumer_key => [12345, 54321])
14
- }.to raise_exception(Twitter::Error::ConfigurationError)
9
+ describe '.new' do
10
+ context 'when invalid credentials are provided' do
11
+ it 'raises a ConfigurationError exception' do
12
+ expect { Twitter::REST::Client.new(:consumer_key => [12_345, 54_321]) }.to raise_exception(Twitter::Error::ConfigurationError)
15
13
  end
16
14
  end
17
15
 
18
- context "when no credentials are provided" do
19
- it "does not raise an exception" do
20
- expect {
21
- Twitter::REST::Client.new
22
- }.not_to raise_error
16
+ context 'when no credentials are provided' do
17
+ it 'does not raise an exception' do
18
+ expect { Twitter::REST::Client.new }.not_to raise_error
23
19
  end
24
20
  end
25
21
  end
26
22
 
27
- describe ".credentials?" do
28
- it "returns true if only bearer_token is supplied" do
29
- client = Twitter::REST::Client.new(:bearer_token => "BT")
23
+ describe '.credentials?' do
24
+ it 'returns true if only bearer_token is supplied' do
25
+ client = Twitter::REST::Client.new(:bearer_token => 'BT')
30
26
  expect(client.credentials?).to be true
31
27
  end
32
- it "returns true if all OAuth credentials are present" do
33
- client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
28
+ it 'returns true if all OAuth credentials are present' do
29
+ client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
34
30
  expect(client.credentials?).to be true
35
31
  end
36
- it "returns false if any credentials are missing" do
37
- client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT")
32
+ it 'returns false if any credentials are missing' do
33
+ client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT')
38
34
  expect(client.credentials?).to be false
39
35
  end
40
36
  end
41
37
 
42
- it "does not cache the screen name across clients" do
43
- stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("sferik.json"), :headers => {:content_type => "application/json; charset=utf-8"})
44
- user1 = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS").current_user
45
- stub_get("/1.1/account/verify_credentials.json").to_return(:body => fixture("pengwynn.json"), :headers => {:content_type => "application/json; charset=utf-8"})
46
- user2 = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS").current_user
38
+ it 'does not cache the screen name across clients' do
39
+ stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('sferik.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
40
+ user1 = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS').current_user
41
+ stub_get('/1.1/account/verify_credentials.json').to_return(:body => fixture('pengwynn.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
42
+ user2 = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS').current_user
47
43
  expect(user1).not_to eq(user2)
48
44
  end
49
45
 
50
- describe "#delete" do
46
+ describe '#delete' do
51
47
  before do
52
- stub_delete("/custom/delete").with(:query => {:deleted => "object"})
48
+ stub_delete('/custom/delete').with(:query => {:deleted => 'object'})
53
49
  end
54
- it "allows custom delete requests" do
55
- @client.delete("/custom/delete", {:deleted => "object"})
56
- expect(a_delete("/custom/delete").with(:query => {:deleted => "object"})).to have_been_made
50
+ it 'allows custom delete requests' do
51
+ @client.delete('/custom/delete', :deleted => 'object')
52
+ expect(a_delete('/custom/delete').with(:query => {:deleted => 'object'})).to have_been_made
57
53
  end
58
54
  end
59
55
 
60
- describe "#put" do
56
+ describe '#put' do
61
57
  before do
62
- stub_put("/custom/put").with(:body => {:updated => "object"})
58
+ stub_put('/custom/put').with(:body => {:updated => 'object'})
63
59
  end
64
- it "allows custom put requests" do
65
- @client.put("/custom/put", {:updated => "object"})
66
- expect(a_put("/custom/put").with(:body => {:updated => "object"})).to have_been_made
60
+ it 'allows custom put requests' do
61
+ @client.put('/custom/put', :updated => 'object')
62
+ expect(a_put('/custom/put').with(:body => {:updated => 'object'})).to have_been_made
67
63
  end
68
64
  end
69
65
 
70
- describe "#user_token?" do
71
- it "returns true if the user token/secret are present" do
72
- client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
66
+ describe '#user_token?' do
67
+ it 'returns true if the user token/secret are present' do
68
+ client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
73
69
  expect(client.user_token?).to be true
74
70
  end
75
- it "returns false if the user token/secret are not completely present" do
76
- client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT")
71
+ it 'returns false if the user token/secret are not completely present' do
72
+ client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT')
77
73
  expect(client.user_token?).to be false
78
74
  end
79
75
  end
80
76
 
81
- describe "#bearer_token?" do
82
- it "returns true if the app token is present" do
83
- client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :bearer_token => "BT")
77
+ describe '#bearer_token?' do
78
+ it 'returns true if the app token is present' do
79
+ client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :bearer_token => 'BT')
84
80
  expect(client.bearer_token?).to be true
85
81
  end
86
- it "returns false if the bearer_token is not present" do
87
- client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS")
82
+ it 'returns false if the bearer_token is not present' do
83
+ client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS')
88
84
  expect(client.bearer_token?).to be false
89
85
  end
90
86
  end
91
87
 
92
- describe "#credentials?" do
93
- it "returns true if all credentials are present" do
94
- client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT", :access_token_secret => "AS")
88
+ describe '#credentials?' do
89
+ it 'returns true if all credentials are present' do
90
+ client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT', :access_token_secret => 'AS')
95
91
  expect(client.credentials?).to be true
96
92
  end
97
- it "returns false if any credentials are missing" do
98
- client = Twitter::REST::Client.new(:consumer_key => "CK", :consumer_secret => "CS", :access_token => "AT")
93
+ it 'returns false if any credentials are missing' do
94
+ client = Twitter::REST::Client.new(:consumer_key => 'CK', :consumer_secret => 'CS', :access_token => 'AT')
99
95
  expect(client.credentials?).to be false
100
96
  end
101
97
  end
102
98
 
103
- describe "#connection" do
104
- it "looks like Faraday connection" do
99
+ describe '#connection' do
100
+ it 'looks like Faraday connection' do
105
101
  expect(@client.send(:connection)).to respond_to(:run_request)
106
102
  end
107
- it "memoizes the connection" do
103
+ it 'memoizes the connection' do
108
104
  c1, c2 = @client.send(:connection), @client.send(:connection)
109
105
  expect(c1.object_id).to eq(c2.object_id)
110
106
  end
111
107
  end
112
108
 
113
- describe "#request" do
114
- it "encodes the entire body when no uploaded media is present" do
115
- stub_post("/1.1/statuses/update.json").with(:body => {:status => "Update"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
116
- @client.update("Update")
117
- expect(a_post("/1.1/statuses/update.json").with(:body => {:status => "Update"})).to have_been_made
109
+ describe '#request' do
110
+ it 'encodes the entire body when no uploaded media is present' do
111
+ stub_post('/1.1/statuses/update.json').with(:body => {:status => 'Update'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
112
+ @client.update('Update')
113
+ expect(a_post('/1.1/statuses/update.json').with(:body => {:status => 'Update'})).to have_been_made
118
114
  end
119
- it "encodes none of the body when uploaded media is present" do
120
- stub_post("/1.1/statuses/update_with_media.json").to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
121
- @client.update_with_media("Update", fixture("pbjt.gif"))
122
- expect(a_post("/1.1/statuses/update_with_media.json")).to have_been_made
115
+ it 'encodes none of the body when uploaded media is present' do
116
+ stub_post('/1.1/statuses/update_with_media.json').to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
117
+ @client.update_with_media('Update', fixture('pbjt.gif'))
118
+ expect(a_post('/1.1/statuses/update_with_media.json')).to have_been_made
123
119
  end
124
- it "catches Faraday errors" do
125
- allow(@client).to receive(:connection).and_raise(Faraday::Error::ClientError.new("Oops"))
126
- expect{@client.send(:request, :get, "/path")}.to raise_error Twitter::Error
120
+ it 'catches Faraday errors' do
121
+ allow(@client).to receive(:connection).and_raise(Faraday::Error::ClientError.new('Oops'))
122
+ expect { @client.send(:request, :get, '/path') }.to raise_error Twitter::Error
127
123
  end
128
- it "catches JSON::ParserError errors" do
129
- allow(@client).to receive(:connection).and_raise(JSON::ParserError.new("unexpected token"))
130
- expect{@client.send(:request, :get, "/path")}.to raise_error Twitter::Error
124
+ it 'catches JSON::ParserError errors' do
125
+ allow(@client).to receive(:connection).and_raise(JSON::ParserError.new('unexpected token'))
126
+ expect { @client.send(:request, :get, '/path') }.to raise_error Twitter::Error
131
127
  end
132
128
  end
133
129
 
134
- describe "#oauth_auth_header" do
135
- it "creates the correct auth headers" do
136
- uri = Twitter::REST::Client::ENDPOINT + "/1.1/direct_messages.json"
130
+ describe '#oauth_auth_header' do
131
+ it 'creates the correct auth headers' do
132
+ uri = Twitter::REST::Client::ENDPOINT + '/1.1/direct_messages.json'
137
133
  authorization = @client.send(:oauth_auth_header, :get, uri)
138
- expect(authorization.options[:signature_method]).to eq("HMAC-SHA1")
139
- expect(authorization.options[:version]).to eq("1.0")
140
- expect(authorization.options[:consumer_key]).to eq("CK")
141
- expect(authorization.options[:consumer_secret]).to eq("CS")
142
- expect(authorization.options[:token]).to eq("AT")
143
- expect(authorization.options[:token_secret]).to eq("AS")
144
- end
145
- it "submits the correct auth header when no media is present" do
134
+ expect(authorization.options[:signature_method]).to eq('HMAC-SHA1')
135
+ expect(authorization.options[:version]).to eq('1.0')
136
+ expect(authorization.options[:consumer_key]).to eq('CK')
137
+ expect(authorization.options[:consumer_secret]).to eq('CS')
138
+ expect(authorization.options[:token]).to eq('AT')
139
+ expect(authorization.options[:token_secret]).to eq('AS')
140
+ end
141
+ it 'submits the correct auth header when no media is present' do
146
142
  # We use static values for nounce and timestamp to get a stable signature
147
- secret = {:consumer_key => "CK", :consumer_secret => "CS",
148
- :token => "OT", :token_secret => "OS",
149
- :nonce => "b6ebe4c2a11af493f8a2290fe1296965", :timestamp => "1370968658"}
150
- header = {"Authorization" => /oauth_signature="FbthwmgGq02iQw%2FuXGEWaL6V6eM%3D"/}
143
+ secret = {:consumer_key => 'CK', :consumer_secret => 'CS',
144
+ :token => 'OT', :token_secret => 'OS',
145
+ :nonce => 'b6ebe4c2a11af493f8a2290fe1296965', :timestamp => '1370968658'}
146
+ header = {'Authorization' => /oauth_signature="FbthwmgGq02iQw%2FuXGEWaL6V6eM%3D"/}
151
147
 
152
148
  allow(@client).to receive(:credentials).and_return(secret)
153
- stub_post("/1.1/statuses/update.json").with(:body => {:status => "Just a test"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
154
- @client.update("Just a test")
155
- expect(a_post("/1.1/statuses/update.json").
149
+ stub_post('/1.1/statuses/update.json').with(:body => {:status => 'Just a test'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
150
+ @client.update('Just a test')
151
+ expect(a_post('/1.1/statuses/update.json').
156
152
  with(:headers => header)).to have_been_made
157
153
  end
158
- it "submits the correct auth header when media is present" do
154
+ it 'submits the correct auth header when media is present' do
159
155
  # We use static values for nounce and timestamp to get a stable signature
160
- secret = {:consumer_key => "CK", :consumer_secret => "CS",
161
- :token => "OT", :token_secret => "OS",
162
- :nonce => "e08201ad0dab4897c99445056feefd95", :timestamp => "1370967652"}
163
- header = {"Authorization" => /oauth_signature="9ziouUPwZT9IWWRbJL8r0BerKYA%3D"/}
156
+ secret = {:consumer_key => 'CK', :consumer_secret => 'CS',
157
+ :token => 'OT', :token_secret => 'OS',
158
+ :nonce => 'e08201ad0dab4897c99445056feefd95', :timestamp => '1370967652'}
159
+ header = {'Authorization' => /oauth_signature="9ziouUPwZT9IWWRbJL8r0BerKYA%3D"/}
164
160
 
165
161
  allow(@client).to receive(:credentials).and_return(secret)
166
- stub_post("/1.1/statuses/update_with_media.json").to_return(:body => fixture("status.json"), :headers => header)
167
- @client.update_with_media("Just a test", fixture("pbjt.gif"))
168
- expect(a_post("/1.1/statuses/update_with_media.json").
162
+ stub_post('/1.1/statuses/update_with_media.json').to_return(:body => fixture('status.json'), :headers => header)
163
+ @client.update_with_media('Just a test', fixture('pbjt.gif'))
164
+ expect(a_post('/1.1/statuses/update_with_media.json').
169
165
  with(:headers => header)).to have_been_made
170
166
  end
171
167
  end
172
168
 
173
- describe "#bearer_auth_header" do
174
- it "creates the correct auth headers with supplied bearer_token" do
175
- client = Twitter::REST::Client.new(:bearer_token => "BT")
169
+ describe '#bearer_auth_header' do
170
+ it 'creates the correct auth headers with supplied bearer_token' do
171
+ client = Twitter::REST::Client.new(:bearer_token => 'BT')
176
172
  authorization = client.send(:bearer_auth_header)
177
- expect(authorization).to eq("Bearer BT")
173
+ expect(authorization).to eq('Bearer BT')
178
174
  end
179
- it "creates the correct auth headers with supplied bearer token" do
180
- token = Twitter::Token.new(:token_type => "bearer", :access_token => "BT")
175
+ it 'creates the correct auth headers with supplied bearer token' do
176
+ token = Twitter::Token.new(:token_type => 'bearer', :access_token => 'BT')
181
177
  client = Twitter::REST::Client.new(:bearer_token => token)
182
178
  authorization = client.send(:bearer_auth_header)
183
- expect(authorization).to eq("Bearer BT")
179
+ expect(authorization).to eq('Bearer BT')
184
180
  end
185
181
  end
186
182
 
187
- describe "#bearer_token_credentials_auth_header" do
188
- it "creates the correct auth header with supplied consumer_key and consumer_secret" do
183
+ describe '#bearer_token_credentials_auth_header' do
184
+ it 'creates the correct auth header with supplied consumer_key and consumer_secret' do
189
185
  authorization = @client.send(:bearer_token_credentials_auth_header)
190
- expect(authorization).to eq("Basic Q0s6Q1M=")
186
+ expect(authorization).to eq('Basic Q0s6Q1M=')
191
187
  end
192
188
  end
193
189
  end
@@ -2,42 +2,42 @@ require 'helper'
2
2
 
3
3
  describe Twitter::SavedSearch do
4
4
 
5
- describe "#==" do
6
- it "returns true when objects IDs are the same" do
7
- saved_search = Twitter::SavedSearch.new(:id => 1, :name => "foo")
8
- other = Twitter::SavedSearch.new(:id => 1, :name => "bar")
5
+ describe '#==' do
6
+ it 'returns true when objects IDs are the same' do
7
+ saved_search = Twitter::SavedSearch.new(:id => 1, :name => 'foo')
8
+ other = Twitter::SavedSearch.new(:id => 1, :name => 'bar')
9
9
  expect(saved_search == other).to be true
10
10
  end
11
- it "returns false when objects IDs are different" do
11
+ it 'returns false when objects IDs are different' do
12
12
  saved_search = Twitter::SavedSearch.new(:id => 1)
13
13
  other = Twitter::SavedSearch.new(:id => 2)
14
14
  expect(saved_search == other).to be false
15
15
  end
16
- it "returns false when classes are different" do
16
+ it 'returns false when classes are different' do
17
17
  saved_search = Twitter::SavedSearch.new(:id => 1)
18
18
  other = Twitter::Identity.new(:id => 1)
19
19
  expect(saved_search == other).to be false
20
20
  end
21
21
  end
22
22
 
23
- describe "#created_at" do
24
- it "returns a Time when created_at is set" do
25
- saved_search = Twitter::SavedSearch.new(:id => 16129012, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
23
+ describe '#created_at' do
24
+ it 'returns a Time when created_at is set' do
25
+ saved_search = Twitter::SavedSearch.new(:id => 16_129_012, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
26
26
  expect(saved_search.created_at).to be_a Time
27
27
  end
28
- it "returns nil when created_at is not set" do
29
- saved_search = Twitter::SavedSearch.new(:id => 16129012)
28
+ it 'returns nil when created_at is not set' do
29
+ saved_search = Twitter::SavedSearch.new(:id => 16_129_012)
30
30
  expect(saved_search.created_at).to be_nil
31
31
  end
32
32
  end
33
33
 
34
- describe "#created?" do
35
- it "returns true when created_at is set" do
36
- saved_search = Twitter::SavedSearch.new(:id => 16129012, :created_at => "Mon Jul 16 12:59:01 +0000 2007")
34
+ describe '#created?' do
35
+ it 'returns true when created_at is set' do
36
+ saved_search = Twitter::SavedSearch.new(:id => 16_129_012, :created_at => 'Mon Jul 16 12:59:01 +0000 2007')
37
37
  expect(saved_search.created?).to be true
38
38
  end
39
- it "returns false when created_at is not set" do
40
- saved_search = Twitter::SavedSearch.new(:id => 16129012)
39
+ it 'returns false when created_at is not set' do
40
+ saved_search = Twitter::SavedSearch.new(:id => 16_129_012)
41
41
  expect(saved_search.created?).to be false
42
42
  end
43
43
  end
@@ -2,124 +2,124 @@ require 'helper'
2
2
 
3
3
  describe Twitter::SearchResults do
4
4
 
5
- describe "#each" do
5
+ describe '#each' do
6
6
  before do
7
7
  @search_results = Twitter::SearchResults.new(:statuses => [{:id => 1}, {:id => 2}, {:id => 3}, {:id => 4}, {:id => 5}, {:id => 6}])
8
8
  end
9
- it "iterates" do
9
+ it 'iterates' do
10
10
  count = 0
11
- @search_results.each{count += 1}
11
+ @search_results.each { count += 1 }
12
12
  expect(count).to eq(6)
13
13
  end
14
- context "with start" do
15
- it "iterates" do
14
+ context 'with start' do
15
+ it 'iterates' do
16
16
  count = 0
17
- @search_results.each(5){count += 1}
17
+ @search_results.each(5) { count += 1 }
18
18
  expect(count).to eq(1)
19
19
  end
20
20
  end
21
21
  end
22
22
 
23
- describe "#completed_in" do
24
- it "returns a number of seconds" do
23
+ describe '#completed_in' do
24
+ it 'returns a number of seconds' do
25
25
  completed_in = Twitter::SearchResults.new(:search_metadata => {:completed_in => 0.029}).completed_in
26
26
  expect(completed_in).to be_a Float
27
27
  expect(completed_in).to eq(0.029)
28
28
  end
29
- it "is nil when not set" do
29
+ it 'is nil when not set' do
30
30
  completed_in = Twitter::SearchResults.new.completed_in
31
31
  expect(completed_in).to be_nil
32
32
  end
33
33
  end
34
34
 
35
- describe "#max_id" do
36
- it "returns an ID" do
37
- max_id = Twitter::SearchResults.new(:search_metadata => {:max_id => 250126199840518145}).max_id
35
+ describe '#max_id' do
36
+ it 'returns an ID' do
37
+ max_id = Twitter::SearchResults.new(:search_metadata => {:max_id => 250_126_199_840_518_145}).max_id
38
38
  expect(max_id).to be_an Integer
39
- expect(max_id).to eq(250126199840518145)
39
+ expect(max_id).to eq(250_126_199_840_518_145)
40
40
  end
41
- it "is nil when not set" do
41
+ it 'is nil when not set' do
42
42
  max_id = Twitter::SearchResults.new.max_id
43
43
  expect(max_id).to be_nil
44
44
  end
45
45
  end
46
46
 
47
- describe "#page" do
48
- it "returns page number" do
47
+ describe '#page' do
48
+ it 'returns page number' do
49
49
  page = Twitter::SearchResults.new(:search_metadata => {:page => 1}).page
50
50
  expect(page).to be_an Integer
51
51
  expect(page).to eq(1)
52
52
  end
53
- it "is nil when not set" do
53
+ it 'is nil when not set' do
54
54
  page = Twitter::SearchResults.new.page
55
55
  expect(page).to be_nil
56
56
  end
57
57
  end
58
58
 
59
- describe "#query" do
60
- it "returns the query" do
61
- query = Twitter::SearchResults.new(:search_metadata => {:query => "%23freebandnames"}).query
59
+ describe '#query' do
60
+ it 'returns the query' do
61
+ query = Twitter::SearchResults.new(:search_metadata => {:query => '%23freebandnames'}).query
62
62
  expect(query).to be_a String
63
- expect(query).to eq("%23freebandnames")
63
+ expect(query).to eq('%23freebandnames')
64
64
  end
65
- it "is nil when not set" do
65
+ it 'is nil when not set' do
66
66
  query = Twitter::SearchResults.new.query
67
67
  expect(query).to be_nil
68
68
  end
69
69
  end
70
70
 
71
- describe "#results_per_page" do
72
- it "returns the number of results per page" do
71
+ describe '#results_per_page' do
72
+ it 'returns the number of results per page' do
73
73
  results_per_page = Twitter::SearchResults.new(:search_metadata => {:count => 4}).results_per_page
74
74
  expect(results_per_page).to be_an Integer
75
75
  expect(results_per_page).to eq(4)
76
76
  end
77
- it "is nil when not set" do
77
+ it 'is nil when not set' do
78
78
  results_per_page = Twitter::SearchResults.new.results_per_page
79
79
  expect(results_per_page).to be_nil
80
80
  end
81
81
  end
82
82
 
83
- describe "#since_id" do
84
- it "returns an ID" do
85
- since_id = Twitter::SearchResults.new(:search_metadata => {:since_id => 250126199840518145}).since_id
83
+ describe '#since_id' do
84
+ it 'returns an ID' do
85
+ since_id = Twitter::SearchResults.new(:search_metadata => {:since_id => 250_126_199_840_518_145}).since_id
86
86
  expect(since_id).to be_an Integer
87
- expect(since_id).to eq(250126199840518145)
87
+ expect(since_id).to eq(250_126_199_840_518_145)
88
88
  end
89
- it "is nil when not set" do
89
+ it 'is nil when not set' do
90
90
  since_id = Twitter::SearchResults.new.since_id
91
91
  expect(since_id).to be_nil
92
92
  end
93
93
  end
94
94
 
95
- describe "#next_results?" do
96
- it "returns true when next_results is set" do
97
- next_results = Twitter::SearchResults.new(:search_metadata => {:next_results => "?"}).next_results?
95
+ describe '#next_results?' do
96
+ it 'returns true when next_results is set' do
97
+ next_results = Twitter::SearchResults.new(:search_metadata => {:next_results => '?'}).next_results?
98
98
  expect(next_results).to be true
99
99
  end
100
- it "returns false when next_results is not set" do
100
+ it 'returns false when next_results is not set' do
101
101
  next_results = Twitter::SearchResults.new(:search_metadata => {}).next_results?
102
102
  expect(next_results).to be false
103
103
  end
104
- it "returns false is search_metadata is not set" do
105
- next_results = Twitter::SearchResults.new().next_results?
104
+ it 'returns false is search_metadata is not set' do
105
+ next_results = Twitter::SearchResults.new.next_results?
106
106
  expect(next_results).to be false
107
107
  end
108
108
  end
109
109
 
110
- describe "#next_results" do
111
- it "returns a hash of query parameters" do
112
- search_results = Twitter::SearchResults.new(:search_metadata => {:next_results => "?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed"})
110
+ describe '#next_results' do
111
+ it 'returns a hash of query parameters' do
112
+ search_results = Twitter::SearchResults.new(:search_metadata => {:next_results => '?max_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=mixed'})
113
113
  expect(search_results.next_results).to be_a Hash
114
- expect(search_results.next_results[:max_id]).to eq("249279667666817023")
114
+ expect(search_results.next_results[:max_id]).to eq('249279667666817023')
115
115
  end
116
116
  end
117
117
 
118
- describe "#refresh_results" do
119
- it "returns a hash of query parameters" do
120
- search_results = Twitter::SearchResults.new(:search_metadata => {:refresh_url => "?since_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=recent"})
118
+ describe '#refresh_results' do
119
+ it 'returns a hash of query parameters' do
120
+ search_results = Twitter::SearchResults.new(:search_metadata => {:refresh_url => '?since_id=249279667666817023&q=%23freebandnames&count=4&include_entities=1&result_type=recent'})
121
121
  expect(search_results.refresh_results).to be_a Hash
122
- expect(search_results.refresh_results[:since_id]).to eq("249279667666817023")
122
+ expect(search_results.refresh_results[:since_id]).to eq('249279667666817023')
123
123
  end
124
124
  end
125
125