twitter 5.1.1 → 5.2.0

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 (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
@@ -2,9 +2,9 @@ require 'helper'
2
2
 
3
3
  describe Twitter::ProfileBanner do
4
4
 
5
- describe "#sizes" do
6
- it "returns a hash of Sizes when sizes is set" do
7
- sizes = Twitter::ProfileBanner.new(:sizes => {:small => {:h => 226, :w => 340, :resize => "fit"}, :large => {:h => 466, :w => 700, :resize => "fit"}, :medium => {:h => 399, :w => 600, :resize => "fit"}, :thumb => {:h => 150, :w => 150, :resize => "crop"}}).sizes
5
+ describe '#sizes' do
6
+ it 'returns a hash of Sizes when sizes is set' do
7
+ sizes = Twitter::ProfileBanner.new(:sizes => {:small => {:h => 226, :w => 340, :resize => 'fit'}, :large => {:h => 466, :w => 700, :resize => 'fit'}, :medium => {:h => 399, :w => 600, :resize => 'fit'}, :thumb => {:h => 150, :w => 150, :resize => 'crop'}}).sizes
8
8
  expect(sizes).to be_a Hash
9
9
  expect(sizes[:small]).to be_a Twitter::Size
10
10
  end
@@ -2,55 +2,55 @@ require 'helper'
2
2
 
3
3
  describe Twitter::RateLimit do
4
4
 
5
- describe "#limit" do
6
- it "returns an Integer when x-rate-limit-limit header is set" do
7
- rate_limit = Twitter::RateLimit.new("x-rate-limit-limit" => "150")
5
+ describe '#limit' do
6
+ it 'returns an Integer when x-rate-limit-limit header is set' do
7
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-limit' => '150')
8
8
  expect(rate_limit.limit).to be_an Integer
9
9
  expect(rate_limit.limit).to eq(150)
10
10
  end
11
- it "returns nil when x-rate-limit-limit header is not set" do
11
+ it 'returns nil when x-rate-limit-limit header is not set' do
12
12
  rate_limit = Twitter::RateLimit.new
13
13
  expect(rate_limit.limit).to be_nil
14
14
  end
15
15
  end
16
16
 
17
- describe "#remaining" do
18
- it "returns an Integer when x-rate-limit-remaining header is set" do
19
- rate_limit = Twitter::RateLimit.new("x-rate-limit-remaining" => "149")
17
+ describe '#remaining' do
18
+ it 'returns an Integer when x-rate-limit-remaining header is set' do
19
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-remaining' => '149')
20
20
  expect(rate_limit.remaining).to be_an Integer
21
21
  expect(rate_limit.remaining).to eq(149)
22
22
  end
23
- it "returns nil when x-rate-limit-remaining header is not set" do
23
+ it 'returns nil when x-rate-limit-remaining header is not set' do
24
24
  rate_limit = Twitter::RateLimit.new
25
25
  expect(rate_limit.remaining).to be_nil
26
26
  end
27
27
  end
28
28
 
29
- describe "#reset_at" do
30
- it "returns a Time when x-rate-limit-reset header is set" do
31
- rate_limit = Twitter::RateLimit.new("x-rate-limit-reset" => "1339019097")
29
+ describe '#reset_at' do
30
+ it 'returns a Time when x-rate-limit-reset header is set' do
31
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-reset' => '1339019097')
32
32
  expect(rate_limit.reset_at).to be_a Time
33
- expect(rate_limit.reset_at).to eq(Time.at(1339019097))
33
+ expect(rate_limit.reset_at).to eq(Time.at(1_339_019_097))
34
34
  end
35
- it "returns nil when x-rate-limit-reset header is not set" do
35
+ it 'returns nil when x-rate-limit-reset header is not set' do
36
36
  rate_limit = Twitter::RateLimit.new
37
37
  expect(rate_limit.reset_at).to be_nil
38
38
  end
39
39
  end
40
40
 
41
- describe "#reset_in" do
41
+ describe '#reset_in' do
42
42
  before do
43
43
  Timecop.freeze(Time.utc(2012, 6, 6, 17, 22, 0))
44
44
  end
45
45
  after do
46
46
  Timecop.return
47
47
  end
48
- it "returns an Integer when x-rate-limit-reset header is set" do
49
- rate_limit = Twitter::RateLimit.new("x-rate-limit-reset" => "1339019097")
48
+ it 'returns an Integer when x-rate-limit-reset header is set' do
49
+ rate_limit = Twitter::RateLimit.new('x-rate-limit-reset' => '1339019097')
50
50
  expect(rate_limit.reset_in).to be_an Integer
51
- expect(rate_limit.reset_in).to eq(15777)
51
+ expect(rate_limit.reset_in).to eq(15_777)
52
52
  end
53
- it "returns nil when x-rate-limit-reset header is not set" do
53
+ it 'returns nil when x-rate-limit-reset header is not set' do
54
54
  rate_limit = Twitter::RateLimit.new
55
55
  expect(rate_limit.reset_in).to be_nil
56
56
  end
@@ -2,45 +2,45 @@ require 'helper'
2
2
 
3
3
  describe Twitter::Relationship do
4
4
 
5
- describe "#source" do
6
- it "returns a User when source is set" do
7
- relationship = Twitter::Relationship.new(:relationship => {:source => {:id => 7505382}})
5
+ describe '#source' do
6
+ it 'returns a User when source is set' do
7
+ relationship = Twitter::Relationship.new(:relationship => {:source => {:id => 7_505_382}})
8
8
  expect(relationship.source).to be_a Twitter::SourceUser
9
9
  end
10
- it "returns nil when source is not set" do
10
+ it 'returns nil when source is not set' do
11
11
  relationship = Twitter::Relationship.new(:relationship => {})
12
12
  expect(relationship.source).to be_nil
13
13
  end
14
14
  end
15
15
 
16
- describe "#source?" do
17
- it "returns true when source is set" do
18
- relationship = Twitter::Relationship.new(:relationship => {:source => {:id => 7505382}})
16
+ describe '#source?' do
17
+ it 'returns true when source is set' do
18
+ relationship = Twitter::Relationship.new(:relationship => {:source => {:id => 7_505_382}})
19
19
  expect(relationship.source?).to be true
20
20
  end
21
- it "returns false when source is not set" do
21
+ it 'returns false when source is not set' do
22
22
  relationship = Twitter::Relationship.new(:relationship => {})
23
23
  expect(relationship.source?).to be false
24
24
  end
25
25
  end
26
26
 
27
- describe "#target" do
28
- it "returns a User when target is set" do
29
- relationship = Twitter::Relationship.new(:relationship => {:target => {:id => 7505382}})
27
+ describe '#target' do
28
+ it 'returns a User when target is set' do
29
+ relationship = Twitter::Relationship.new(:relationship => {:target => {:id => 7_505_382}})
30
30
  expect(relationship.target).to be_a Twitter::TargetUser
31
31
  end
32
- it "returns nil when target is not set" do
32
+ it 'returns nil when target is not set' do
33
33
  relationship = Twitter::Relationship.new(:relationship => {})
34
34
  expect(relationship.target).to be_nil
35
35
  end
36
36
  end
37
37
 
38
- describe "#target?" do
39
- it "returns true when target is set" do
40
- relationship = Twitter::Relationship.new(:relationship => {:target => {:id => 7505382}})
38
+ describe '#target?' do
39
+ it 'returns true when target is set' do
40
+ relationship = Twitter::Relationship.new(:relationship => {:target => {:id => 7_505_382}})
41
41
  expect(relationship.target?).to be true
42
42
  end
43
- it "returns false when target is not set" do
43
+ it 'returns false when target is not set' do
44
44
  relationship = Twitter::Relationship.new(:relationship => {})
45
45
  expect(relationship.target?).to be false
46
46
  end
@@ -3,129 +3,129 @@ require 'helper'
3
3
  describe Twitter::REST::API::DirectMessages 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 "#direct_messages_received" do
9
+ describe '#direct_messages_received' do
10
10
  before do
11
- stub_get("/1.1/direct_messages.json").to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
11
+ stub_get('/1.1/direct_messages.json').to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
12
12
  end
13
- it "requests the correct resource" do
13
+ it 'requests the correct resource' do
14
14
  @client.direct_messages_received
15
- expect(a_get("/1.1/direct_messages.json")).to have_been_made
15
+ expect(a_get('/1.1/direct_messages.json')).to have_been_made
16
16
  end
17
- it "returns the 20 most recent direct messages sent to the authenticating user" do
17
+ it 'returns the 20 most recent direct messages sent to the authenticating user' do
18
18
  direct_messages = @client.direct_messages_received
19
19
  expect(direct_messages).to be_an Array
20
20
  expect(direct_messages.first).to be_a Twitter::DirectMessage
21
- expect(direct_messages.first.sender.id).to eq(7505382)
21
+ expect(direct_messages.first.sender.id).to eq(7_505_382)
22
22
  end
23
23
  end
24
24
 
25
- describe "#direct_messages_sent" do
25
+ describe '#direct_messages_sent' do
26
26
  before do
27
- stub_get("/1.1/direct_messages/sent.json").to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
27
+ stub_get('/1.1/direct_messages/sent.json').to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
28
28
  end
29
- it "requests the correct resource" do
29
+ it 'requests the correct resource' do
30
30
  @client.direct_messages_sent
31
- expect(a_get("/1.1/direct_messages/sent.json")).to have_been_made
31
+ expect(a_get('/1.1/direct_messages/sent.json')).to have_been_made
32
32
  end
33
- it "returns the 20 most recent direct messages sent by the authenticating user" do
33
+ it 'returns the 20 most recent direct messages sent by the authenticating user' do
34
34
  direct_messages = @client.direct_messages_sent
35
35
  expect(direct_messages).to be_an Array
36
36
  expect(direct_messages.first).to be_a Twitter::DirectMessage
37
- expect(direct_messages.first.sender.id).to eq(7505382)
37
+ expect(direct_messages.first.sender.id).to eq(7_505_382)
38
38
  end
39
39
  end
40
40
 
41
- describe "#direct_message" do
41
+ describe '#direct_message' do
42
42
  before do
43
- stub_get("/1.1/direct_messages/show.json").with(:query => {:id => "1825786345"}).to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
43
+ stub_get('/1.1/direct_messages/show.json').with(:query => {:id => '1825786345'}).to_return(:body => fixture('direct_message.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
44
44
  end
45
- it "requests the correct resource" do
46
- @client.direct_message(1825786345)
47
- expect(a_get("/1.1/direct_messages/show.json").with(:query => {:id => "1825786345"})).to have_been_made
45
+ it 'requests the correct resource' do
46
+ @client.direct_message(1_825_786_345)
47
+ expect(a_get('/1.1/direct_messages/show.json').with(:query => {:id => '1825786345'})).to have_been_made
48
48
  end
49
- it "returns the specified direct message" do
50
- direct_message = @client.direct_message(1825786345)
49
+ it 'returns the specified direct message' do
50
+ direct_message = @client.direct_message(1_825_786_345)
51
51
  expect(direct_message).to be_a Twitter::DirectMessage
52
- expect(direct_message.sender.id).to eq(7505382)
52
+ expect(direct_message.sender.id).to eq(7_505_382)
53
53
  end
54
54
  end
55
55
 
56
- describe "#direct_messages" do
57
- context "with ids passed" do
56
+ describe '#direct_messages' do
57
+ context 'with ids passed' do
58
58
  before do
59
- stub_get("/1.1/direct_messages/show.json").with(:query => {:id => "1825786345"}).to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
59
+ stub_get('/1.1/direct_messages/show.json').with(:query => {:id => '1825786345'}).to_return(:body => fixture('direct_message.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
60
60
  end
61
- it "requests the correct resource" do
62
- @client.direct_messages(1825786345)
63
- expect(a_get("/1.1/direct_messages/show.json").with(:query => {:id => "1825786345"})).to have_been_made
61
+ it 'requests the correct resource' do
62
+ @client.direct_messages(1_825_786_345)
63
+ expect(a_get('/1.1/direct_messages/show.json').with(:query => {:id => '1825786345'})).to have_been_made
64
64
  end
65
- it "returns an array of direct messages" do
66
- direct_messages = @client.direct_messages(1825786345)
65
+ it 'returns an array of direct messages' do
66
+ direct_messages = @client.direct_messages(1_825_786_345)
67
67
  expect(direct_messages).to be_an Array
68
68
  expect(direct_messages.first).to be_a Twitter::DirectMessage
69
- expect(direct_messages.first.sender.id).to eq(7505382)
69
+ expect(direct_messages.first.sender.id).to eq(7_505_382)
70
70
  end
71
71
  end
72
- context "without ids passed" do
72
+ context 'without ids passed' do
73
73
  before do
74
- stub_get("/1.1/direct_messages.json").to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"})
74
+ stub_get('/1.1/direct_messages.json').to_return(:body => fixture('direct_messages.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
75
75
  end
76
- it "requests the correct resource" do
76
+ it 'requests the correct resource' do
77
77
  @client.direct_messages
78
- expect(a_get("/1.1/direct_messages.json")).to have_been_made
78
+ expect(a_get('/1.1/direct_messages.json')).to have_been_made
79
79
  end
80
- it "returns the 20 most recent direct messages sent to the authenticating user" do
80
+ it 'returns the 20 most recent direct messages sent to the authenticating user' do
81
81
  direct_messages = @client.direct_messages
82
82
  expect(direct_messages).to be_an Array
83
83
  expect(direct_messages.first).to be_a Twitter::DirectMessage
84
- expect(direct_messages.first.sender.id).to eq(7505382)
84
+ expect(direct_messages.first.sender.id).to eq(7_505_382)
85
85
  end
86
86
  end
87
87
  end
88
88
 
89
- describe "#destroy_direct_message" do
89
+ describe '#destroy_direct_message' do
90
90
  before do
91
- stub_post("/1.1/direct_messages/destroy.json").with(:body => {:id => "1825785544"}).to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
91
+ stub_post('/1.1/direct_messages/destroy.json').with(:body => {:id => '1825785544'}).to_return(:body => fixture('direct_message.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
92
92
  end
93
- it "requests the correct resource" do
94
- @client.destroy_direct_message(1825785544)
95
- expect(a_post("/1.1/direct_messages/destroy.json").with(:body => {:id => "1825785544"})).to have_been_made
93
+ it 'requests the correct resource' do
94
+ @client.destroy_direct_message(1_825_785_544)
95
+ expect(a_post('/1.1/direct_messages/destroy.json').with(:body => {:id => '1825785544'})).to have_been_made
96
96
  end
97
- it "returns an array of deleted messages" do
98
- direct_messages = @client.destroy_direct_message(1825785544)
97
+ it 'returns an array of deleted messages' do
98
+ direct_messages = @client.destroy_direct_message(1_825_785_544)
99
99
  expect(direct_messages).to be_an Array
100
100
  expect(direct_messages.first).to be_a Twitter::DirectMessage
101
- expect(direct_messages.first.sender.id).to eq(7505382)
101
+ expect(direct_messages.first.sender.id).to eq(7_505_382)
102
102
  end
103
103
  end
104
104
 
105
- describe "#create_direct_message" do
105
+ describe '#create_direct_message' do
106
106
  before do
107
- stub_post("/1.1/direct_messages/new.json").with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"}).to_return(:body => fixture("direct_message.json"), :headers => {:content_type => "application/json; charset=utf-8"})
107
+ stub_post('/1.1/direct_messages/new.json').with(:body => {:screen_name => 'pengwynn', :text => 'Creating a fixture for the Twitter gem'}).to_return(:body => fixture('direct_message.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
108
108
  end
109
- it "requests the correct resource" do
110
- @client.create_direct_message("pengwynn", "Creating a fixture for the Twitter gem")
111
- expect(a_post("/1.1/direct_messages/new.json").with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"})).to have_been_made
109
+ it 'requests the correct resource' do
110
+ @client.create_direct_message('pengwynn', 'Creating a fixture for the Twitter gem')
111
+ expect(a_post('/1.1/direct_messages/new.json').with(:body => {:screen_name => 'pengwynn', :text => 'Creating a fixture for the Twitter gem'})).to have_been_made
112
112
  end
113
- it "returns the sent message" do
114
- direct_message = @client.create_direct_message("pengwynn", "Creating a fixture for the Twitter gem")
113
+ it 'returns the sent message' do
114
+ direct_message = @client.create_direct_message('pengwynn', 'Creating a fixture for the Twitter gem')
115
115
  expect(direct_message).to be_a Twitter::DirectMessage
116
- expect(direct_message.text).to eq("Creating a fixture for the Twitter gem")
116
+ expect(direct_message.text).to eq('Creating a fixture for the Twitter gem')
117
117
  end
118
- context "with a URI object passed" do
119
- it "requests the correct resource" do
120
- user = URI.parse("https://twitter.com/pengwynn")
121
- @client.create_direct_message(user, "Creating a fixture for the Twitter gem")
122
- expect(a_post("/1.1/direct_messages/new.json").with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"})).to have_been_made
118
+ context 'with a URI object passed' do
119
+ it 'requests the correct resource' do
120
+ user = URI.parse('https://twitter.com/pengwynn')
121
+ @client.create_direct_message(user, 'Creating a fixture for the Twitter gem')
122
+ expect(a_post('/1.1/direct_messages/new.json').with(:body => {:screen_name => 'pengwynn', :text => 'Creating a fixture for the Twitter gem'})).to have_been_made
123
123
  end
124
124
  end
125
- context "with a URI string passed" do
126
- it "requests the correct resource" do
127
- @client.create_direct_message("https://twitter.com/pengwynn", "Creating a fixture for the Twitter gem")
128
- expect(a_post("/1.1/direct_messages/new.json").with(:body => {:screen_name => "pengwynn", :text => "Creating a fixture for the Twitter gem"})).to have_been_made
125
+ context 'with a URI string passed' do
126
+ it 'requests the correct resource' do
127
+ @client.create_direct_message('https://twitter.com/pengwynn', 'Creating a fixture for the Twitter gem')
128
+ expect(a_post('/1.1/direct_messages/new.json').with(:body => {:screen_name => 'pengwynn', :text => 'Creating a fixture for the Twitter gem'})).to have_been_made
129
129
  end
130
130
  end
131
131
  end
@@ -3,183 +3,183 @@ require 'helper'
3
3
  describe Twitter::REST::API::Favorites 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 "#favorites" do
10
- context "with a screen name passed" do
9
+ describe '#favorites' do
10
+ context 'with a screen name passed' do
11
11
  before do
12
- stub_get("/1.1/favorites/list.json").with(:query => {:screen_name => "sferik"}).to_return(:body => fixture("user_timeline.json"), :headers => {:content_type => "application/json; charset=utf-8"})
12
+ stub_get('/1.1/favorites/list.json').with(:query => {:screen_name => 'sferik'}).to_return(:body => fixture('user_timeline.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
13
13
  end
14
- it "requests the correct resource" do
15
- @client.favorites("sferik")
16
- expect(a_get("/1.1/favorites/list.json").with(:query => {:screen_name => "sferik"})).to have_been_made
14
+ it 'requests the correct resource' do
15
+ @client.favorites('sferik')
16
+ expect(a_get('/1.1/favorites/list.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
17
17
  end
18
- it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do
19
- favorites = @client.favorites("sferik")
18
+ it 'returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter' do
19
+ favorites = @client.favorites('sferik')
20
20
  expect(favorites).to be_an Array
21
21
  expect(favorites.first).to be_a Twitter::Tweet
22
- expect(favorites.first.user.id).to eq(7505382)
22
+ expect(favorites.first.user.id).to eq(7_505_382)
23
23
  end
24
- context "with a URI object passed" do
25
- it "requests the correct resource" do
26
- user = URI.parse("https://twitter.com/sferik")
24
+ context 'with a URI object passed' do
25
+ it 'requests the correct resource' do
26
+ user = URI.parse('https://twitter.com/sferik')
27
27
  @client.favorites(user)
28
- expect(a_get("/1.1/favorites/list.json").with(:query => {:screen_name => "sferik"})).to have_been_made
28
+ expect(a_get('/1.1/favorites/list.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
29
29
  end
30
30
  end
31
- context "with a URI string passed" do
32
- it "requests the correct resource" do
33
- @client.favorites("https://twitter.com/sferik")
34
- expect(a_get("/1.1/favorites/list.json").with(:query => {:screen_name => "sferik"})).to have_been_made
31
+ context 'with a URI string passed' do
32
+ it 'requests the correct resource' do
33
+ @client.favorites('https://twitter.com/sferik')
34
+ expect(a_get('/1.1/favorites/list.json').with(:query => {:screen_name => 'sferik'})).to have_been_made
35
35
  end
36
36
  end
37
37
  end
38
- context "without arguments passed" do
38
+ context 'without arguments passed' do
39
39
  before do
40
- stub_get("/1.1/favorites/list.json").to_return(:body => fixture("user_timeline.json"), :headers => {:content_type => "application/json; charset=utf-8"})
40
+ stub_get('/1.1/favorites/list.json').to_return(:body => fixture('user_timeline.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
41
41
  end
42
- it "requests the correct resource" do
42
+ it 'requests the correct resource' do
43
43
  @client.favorites
44
- expect(a_get("/1.1/favorites/list.json")).to have_been_made
44
+ expect(a_get('/1.1/favorites/list.json')).to have_been_made
45
45
  end
46
- it "returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter" do
46
+ it 'returns the 20 most recent favorite Tweets for the authenticating user or user specified by the ID parameter' do
47
47
  favorites = @client.favorites
48
48
  expect(favorites).to be_an Array
49
49
  expect(favorites.first).to be_a Twitter::Tweet
50
- expect(favorites.first.user.id).to eq(7505382)
50
+ expect(favorites.first.user.id).to eq(7_505_382)
51
51
  end
52
52
  end
53
53
  end
54
54
 
55
- describe "#unfavorite" do
55
+ describe '#unfavorite' do
56
56
  before do
57
- stub_post("/1.1/favorites/destroy.json").with(:body => {:id => "25938088801"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
57
+ stub_post('/1.1/favorites/destroy.json').with(:body => {:id => '25938088801'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
58
58
  end
59
- it "requests the correct resource" do
60
- @client.unfavorite(25938088801)
61
- expect(a_post("/1.1/favorites/destroy.json").with(:body => {:id => "25938088801"})).to have_been_made
59
+ it 'requests the correct resource' do
60
+ @client.unfavorite(25_938_088_801)
61
+ expect(a_post('/1.1/favorites/destroy.json').with(:body => {:id => '25938088801'})).to have_been_made
62
62
  end
63
- it "returns an array of un-favorited Tweets" do
64
- tweets = @client.unfavorite(25938088801)
63
+ it 'returns an array of un-favorited Tweets' do
64
+ tweets = @client.unfavorite(25_938_088_801)
65
65
  expect(tweets).to be_an Array
66
66
  expect(tweets.first).to be_a Twitter::Tweet
67
67
  expect(tweets.first.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
68
68
  end
69
- context "with a URI object passed" do
70
- it "requests the correct resource" do
71
- tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
69
+ context 'with a URI object passed' do
70
+ it 'requests the correct resource' do
71
+ tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
72
72
  @client.unfavorite(tweet)
73
- expect(a_post("/1.1/favorites/destroy.json").with(:body => {:id => "25938088801"})).to have_been_made
73
+ expect(a_post('/1.1/favorites/destroy.json').with(:body => {:id => '25938088801'})).to have_been_made
74
74
  end
75
75
  end
76
- context "with a URI string passed" do
77
- it "requests the correct resource" do
78
- @client.unfavorite("https://twitter.com/sferik/status/25938088801")
79
- expect(a_post("/1.1/favorites/destroy.json").with(:body => {:id => "25938088801"})).to have_been_made
76
+ context 'with a URI string passed' do
77
+ it 'requests the correct resource' do
78
+ @client.unfavorite('https://twitter.com/sferik/status/25938088801')
79
+ expect(a_post('/1.1/favorites/destroy.json').with(:body => {:id => '25938088801'})).to have_been_made
80
80
  end
81
81
  end
82
- context "with a Tweet passed" do
83
- it "requests the correct resource" do
84
- tweet = Twitter::Tweet.new(:id => 25938088801)
82
+ context 'with a Tweet passed' do
83
+ it 'requests the correct resource' do
84
+ tweet = Twitter::Tweet.new(:id => 25_938_088_801)
85
85
  @client.unfavorite(tweet)
86
- expect(a_post("/1.1/favorites/destroy.json").with(:body => {:id => "25938088801"})).to have_been_made
86
+ expect(a_post('/1.1/favorites/destroy.json').with(:body => {:id => '25938088801'})).to have_been_made
87
87
  end
88
88
  end
89
89
  end
90
90
 
91
- describe "#favorite" do
91
+ describe '#favorite' do
92
92
  before do
93
- stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
93
+ stub_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
94
94
  end
95
- it "requests the correct resource" do
96
- @client.favorite(25938088801)
97
- expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
95
+ it 'requests the correct resource' do
96
+ @client.favorite(25_938_088_801)
97
+ expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'})).to have_been_made
98
98
  end
99
- it "returns an array of favorited Tweets" do
100
- tweets = @client.favorite(25938088801)
99
+ it 'returns an array of favorited Tweets' do
100
+ tweets = @client.favorite(25_938_088_801)
101
101
  expect(tweets).to be_an Array
102
102
  expect(tweets.first).to be_a Twitter::Tweet
103
103
  expect(tweets.first.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
104
104
  end
105
- context "already favorited" do
105
+ context 'already favorited' do
106
106
  before do
107
- stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:status => 403, :body => fixture("already_favorited.json"), :headers => {:content_type => "application/json; charset=utf-8"})
107
+ stub_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'}).to_return(:status => 403, :body => fixture('already_favorited.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
108
108
  end
109
- it "does not raises an error" do
110
- expect{@client.favorite(25938088801)}.not_to raise_error
109
+ it 'does not raises an error' do
110
+ expect { @client.favorite(25_938_088_801) }.not_to raise_error
111
111
  end
112
112
  end
113
- context "with a URI object passed" do
114
- it "requests the correct resource" do
115
- tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
113
+ context 'with a URI object passed' do
114
+ it 'requests the correct resource' do
115
+ tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
116
116
  @client.favorite(tweet)
117
- expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
117
+ expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'})).to have_been_made
118
118
  end
119
119
  end
120
- context "with a URI string passed" do
121
- it "requests the correct resource" do
122
- @client.favorite("https://twitter.com/sferik/status/25938088801")
123
- expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
120
+ context 'with a URI string passed' do
121
+ it 'requests the correct resource' do
122
+ @client.favorite('https://twitter.com/sferik/status/25938088801')
123
+ expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'})).to have_been_made
124
124
  end
125
125
  end
126
- context "with a Tweet passed" do
127
- it "requests the correct resource" do
128
- tweet = Twitter::Tweet.new(:id => 25938088801)
126
+ context 'with a Tweet passed' do
127
+ it 'requests the correct resource' do
128
+ tweet = Twitter::Tweet.new(:id => 25_938_088_801)
129
129
  @client.favorite(tweet)
130
- expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
130
+ expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'})).to have_been_made
131
131
  end
132
132
  end
133
133
  end
134
134
 
135
- describe "#favorite!" do
135
+ describe '#favorite!' do
136
136
  before do
137
- stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:body => fixture("status.json"), :headers => {:content_type => "application/json; charset=utf-8"})
137
+ stub_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'}).to_return(:body => fixture('status.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
138
138
  end
139
- it "requests the correct resource" do
140
- @client.favorite!(25938088801)
141
- expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
139
+ it 'requests the correct resource' do
140
+ @client.favorite!(25_938_088_801)
141
+ expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'})).to have_been_made
142
142
  end
143
- it "returns an array of favorited Tweets" do
144
- tweets = @client.favorite!(25938088801)
143
+ it 'returns an array of favorited Tweets' do
144
+ tweets = @client.favorite!(25_938_088_801)
145
145
  expect(tweets).to be_an Array
146
146
  expect(tweets.first).to be_a Twitter::Tweet
147
147
  expect(tweets.first.text).to eq("The problem with your code is that it's doing exactly what you told it to do.")
148
148
  end
149
- context "forbidden" do
149
+ context 'forbidden' do
150
150
  before do
151
- stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:status => 403, :headers => {:content_type => "application/json; charset=utf-8"})
151
+ stub_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'}).to_return(:status => 403, :headers => {:content_type => 'application/json; charset=utf-8'})
152
152
  end
153
- it "raises a Forbidden error" do
154
- expect{@client.favorite!(25938088801)}.to raise_error Twitter::Error::Forbidden
153
+ it 'raises a Forbidden error' do
154
+ expect { @client.favorite!(25_938_088_801) }.to raise_error Twitter::Error::Forbidden
155
155
  end
156
156
  end
157
- context "already favorited" do
157
+ context 'already favorited' do
158
158
  before do
159
- stub_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"}).to_return(:status => 403, :body => fixture("already_favorited.json"), :headers => {:content_type => "application/json; charset=utf-8"})
159
+ stub_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'}).to_return(:status => 403, :body => fixture('already_favorited.json'), :headers => {:content_type => 'application/json; charset=utf-8'})
160
160
  end
161
- it "raises an AlreadyFavorited error" do
162
- expect{@client.favorite!(25938088801)}.to raise_error Twitter::Error::AlreadyFavorited
161
+ it 'raises an AlreadyFavorited error' do
162
+ expect { @client.favorite!(25_938_088_801) }.to raise_error Twitter::Error::AlreadyFavorited
163
163
  end
164
164
  end
165
- context "with a URI object passed" do
166
- it "requests the correct resource" do
167
- tweet = URI.parse("https://twitter.com/sferik/status/25938088801")
165
+ context 'with a URI object passed' do
166
+ it 'requests the correct resource' do
167
+ tweet = URI.parse('https://twitter.com/sferik/status/25938088801')
168
168
  @client.favorite!(tweet)
169
- expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
169
+ expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'})).to have_been_made
170
170
  end
171
171
  end
172
- context "with a URI string passed" do
173
- it "requests the correct resource" do
174
- @client.favorite!("https://twitter.com/sferik/status/25938088801")
175
- expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
172
+ context 'with a URI string passed' do
173
+ it 'requests the correct resource' do
174
+ @client.favorite!('https://twitter.com/sferik/status/25938088801')
175
+ expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'})).to have_been_made
176
176
  end
177
177
  end
178
- context "with a Tweet passed" do
179
- it "requests the correct resource" do
180
- tweet = Twitter::Tweet.new(:id => 25938088801)
178
+ context 'with a Tweet passed' do
179
+ it 'requests the correct resource' do
180
+ tweet = Twitter::Tweet.new(:id => 25_938_088_801)
181
181
  @client.favorite!(tweet)
182
- expect(a_post("/1.1/favorites/create.json").with(:body => {:id => "25938088801"})).to have_been_made
182
+ expect(a_post('/1.1/favorites/create.json').with(:body => {:id => '25938088801'})).to have_been_made
183
183
  end
184
184
  end
185
185
  end