instagram-continued-continued 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.hound.yml +2 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +15 -0
  6. data/.travis.yml +20 -0
  7. data/.yardopts +9 -0
  8. data/Gemfile +3 -0
  9. data/LICENSE.md +30 -0
  10. data/PATENTS.md +23 -0
  11. data/README.md +15 -0
  12. data/Rakefile +23 -0
  13. data/instagram-continued-continued.gemspec +34 -0
  14. data/lib/faraday/loud_logger.rb +74 -0
  15. data/lib/faraday/oauth2.rb +40 -0
  16. data/lib/faraday/raise_http_exception.rb +61 -0
  17. data/lib/instagram.rb +28 -0
  18. data/lib/instagram/api.rb +31 -0
  19. data/lib/instagram/client.rb +21 -0
  20. data/lib/instagram/client/comments.rb +62 -0
  21. data/lib/instagram/client/embedding.rb +28 -0
  22. data/lib/instagram/client/geographies.rb +29 -0
  23. data/lib/instagram/client/likes.rb +58 -0
  24. data/lib/instagram/client/locations.rb +75 -0
  25. data/lib/instagram/client/media.rb +82 -0
  26. data/lib/instagram/client/subscriptions.rb +211 -0
  27. data/lib/instagram/client/tags.rb +59 -0
  28. data/lib/instagram/client/users.rb +310 -0
  29. data/lib/instagram/client/utils.rb +28 -0
  30. data/lib/instagram/configuration.rb +123 -0
  31. data/lib/instagram/connection.rb +33 -0
  32. data/lib/instagram/error.rb +34 -0
  33. data/lib/instagram/hashie_wrapper.rb +8 -0
  34. data/lib/instagram/oauth.rb +36 -0
  35. data/lib/instagram/request.rb +79 -0
  36. data/lib/instagram/response.rb +27 -0
  37. data/lib/instagram/version.rb +3 -0
  38. data/spec/faraday/response_spec.rb +85 -0
  39. data/spec/fixtures/access_token.json +9 -0
  40. data/spec/fixtures/approve_user.json +8 -0
  41. data/spec/fixtures/block_user.json +8 -0
  42. data/spec/fixtures/deny_user.json +8 -0
  43. data/spec/fixtures/follow_user.json +8 -0
  44. data/spec/fixtures/followed_by.json +1 -0
  45. data/spec/fixtures/follows.json +1 -0
  46. data/spec/fixtures/geography_recent_media.json +1 -0
  47. data/spec/fixtures/liked_media.json +1 -0
  48. data/spec/fixtures/location.json +1 -0
  49. data/spec/fixtures/location_recent_media.json +1 -0
  50. data/spec/fixtures/location_search.json +1 -0
  51. data/spec/fixtures/location_search_facebook.json +1 -0
  52. data/spec/fixtures/media.json +1 -0
  53. data/spec/fixtures/media_comment.json +1 -0
  54. data/spec/fixtures/media_comment_deleted.json +1 -0
  55. data/spec/fixtures/media_comments.json +1 -0
  56. data/spec/fixtures/media_liked.json +1 -0
  57. data/spec/fixtures/media_likes.json +1 -0
  58. data/spec/fixtures/media_popular.json +1 -0
  59. data/spec/fixtures/media_search.json +1 -0
  60. data/spec/fixtures/media_shortcode.json +1 -0
  61. data/spec/fixtures/media_unliked.json +1 -0
  62. data/spec/fixtures/mikeyk.json +1 -0
  63. data/spec/fixtures/oembed.json +14 -0
  64. data/spec/fixtures/recent_media.json +1 -0
  65. data/spec/fixtures/relationship.json +9 -0
  66. data/spec/fixtures/requested_by.json +12 -0
  67. data/spec/fixtures/shayne.json +1 -0
  68. data/spec/fixtures/subscription.json +12 -0
  69. data/spec/fixtures/subscription_deleted.json +1 -0
  70. data/spec/fixtures/subscription_payload.json +14 -0
  71. data/spec/fixtures/subscriptions.json +22 -0
  72. data/spec/fixtures/tag.json +1 -0
  73. data/spec/fixtures/tag_recent_media.json +1 -0
  74. data/spec/fixtures/tag_search.json +1 -0
  75. data/spec/fixtures/unblock_user.json +8 -0
  76. data/spec/fixtures/unfollow_user.json +8 -0
  77. data/spec/fixtures/user_media_feed.json +1 -0
  78. data/spec/fixtures/user_search.json +1 -0
  79. data/spec/instagram/api_spec.rb +259 -0
  80. data/spec/instagram/client/comments_spec.rb +67 -0
  81. data/spec/instagram/client/embedding_spec.rb +36 -0
  82. data/spec/instagram/client/geography_spec.rb +34 -0
  83. data/spec/instagram/client/likes_spec.rb +62 -0
  84. data/spec/instagram/client/locations_spec.rb +121 -0
  85. data/spec/instagram/client/media_spec.rb +95 -0
  86. data/spec/instagram/client/subscriptions_spec.rb +162 -0
  87. data/spec/instagram/client/tags_spec.rb +75 -0
  88. data/spec/instagram/client/users_spec.rb +407 -0
  89. data/spec/instagram/client/utils_spec.rb +31 -0
  90. data/spec/instagram/client_spec.rb +23 -0
  91. data/spec/instagram/request_spec.rb +56 -0
  92. data/spec/instagram_spec.rb +105 -0
  93. data/spec/spec_helper.rb +66 -0
  94. metadata +293 -0
@@ -0,0 +1,36 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ describe Instagram::Client do
4
+ Instagram::Configuration::VALID_FORMATS.each do |format|
5
+ context ".new(:format => '#{format}')" do
6
+ before do
7
+ @client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", access_token: "AT")
8
+ end
9
+
10
+ describe ".oembed" do
11
+ before do
12
+ stub_get("oembed")
13
+ .with(query: { access_token: @client.access_token, url: "http://instagram.com/p/abcdef" })
14
+ .to_return(body: fixture("oembed.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
15
+ end
16
+
17
+ it "should get the correct resource" do
18
+ @client.oembed("http://instagram.com/p/abcdef")
19
+ expect(a_get("oembed?url=http://instagram.com/p/abcdef")
20
+ .with(query: { access_token: @client.access_token }))
21
+ .to have_been_made
22
+ end
23
+
24
+ it "should return the oembed information for an instagram media url" do
25
+ oembed = @client.oembed("http://instagram.com/p/abcdef")
26
+ expect(oembed.media_id).to eq("123657555223544123_41812344")
27
+ end
28
+
29
+ it "should return nil if a URL is not provided" do
30
+ oembed = @client.oembed
31
+ expect(oembed).to be_nil
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,34 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ describe Instagram::Client do
4
+ Instagram::Configuration::VALID_FORMATS.each do |format|
5
+ context ".new(:format => '#{format}')" do
6
+ before do
7
+ @client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", access_token: "AT")
8
+ end
9
+
10
+ describe ".geography_recent_media" do
11
+ context "with geography ID passed" do
12
+ before do
13
+ stub_get("geographies/12345/media/recent.#{format}")
14
+ .with(query: { access_token: @client.access_token })
15
+ .to_return(body: fixture("geography_recent_media.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
16
+ end
17
+
18
+ it "should get the correct resource" do
19
+ @client.geography_recent_media(12_345)
20
+ expect(a_get("geographies/12345/media/recent.#{format}")
21
+ .with(query: { access_token: @client.access_token }))
22
+ .to have_been_made
23
+ end
24
+
25
+ it "should return a list of recent media items within the specifed geography" do
26
+ recent_media = @client.geography_recent_media(12_345)
27
+ expect(recent_media).to be_a Array
28
+ expect(recent_media.first.user.username).to eq("amandavan")
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,62 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ describe Instagram::Client do
4
+ Instagram::Configuration::VALID_FORMATS.each do |format|
5
+ context ".new(:format => '#{format}')" do
6
+ before do
7
+ @client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", client_ips: "1.2.3.4", access_token: "AT")
8
+ end
9
+
10
+ describe ".media_likes" do
11
+ before do
12
+ stub_get("media/777/likes.#{format}")
13
+ .with(query: { access_token: @client.access_token })
14
+ .to_return(body: fixture("media_likes.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
15
+ end
16
+
17
+ it "should get the correct resource" do
18
+ @client.media_likes(777)
19
+ expect(a_get("media/777/likes.#{format}")
20
+ .with(query: { access_token: @client.access_token }))
21
+ .to have_been_made
22
+ end
23
+
24
+ it "should return an array of user search results" do
25
+ comments = @client.media_likes(777)
26
+ expect(comments).to be_a Array
27
+ expect(comments.first.username).to eq("chris")
28
+ end
29
+ end
30
+
31
+ describe ".like_media" do
32
+ before do
33
+ stub_post("media/777/likes.#{format}")
34
+ .with(body: { access_token: @client.access_token })
35
+ .to_return(body: fixture("media_liked.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
36
+ end
37
+
38
+ it "should get the correct resource" do
39
+ @client.like_media(777)
40
+ expect(a_post("media/777/likes.#{format}")
41
+ .with(body: { access_token: @client.access_token }))
42
+ .to have_been_made
43
+ end
44
+ end
45
+
46
+ describe ".unlike_media" do
47
+ before do
48
+ stub_delete("media/777/likes.#{format}")
49
+ .with(query: { access_token: @client.access_token })
50
+ .to_return(body: fixture("media_unliked.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
51
+ end
52
+
53
+ it "should get the correct resource" do
54
+ @client.unlike_media(777)
55
+ expect(a_delete("media/777/likes.#{format}")
56
+ .with(query: { access_token: @client.access_token }))
57
+ .to have_been_made
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,121 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ describe Instagram::Client do
4
+ Instagram::Configuration::VALID_FORMATS.each do |format|
5
+ context ".new(:format => '#{format}')" do
6
+ before do
7
+ @client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", access_token: "AT")
8
+ end
9
+
10
+ describe ".location" do
11
+ before do
12
+ stub_get("locations/514276.#{format}")
13
+ .with(query: { access_token: @client.access_token })
14
+ .to_return(body: fixture("location.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
15
+ end
16
+
17
+ it "should get the correct resource" do
18
+ @client.location(514_276)
19
+ expect(a_get("locations/514276.#{format}")
20
+ .with(query: { access_token: @client.access_token }))
21
+ .to have_been_made
22
+ end
23
+
24
+ it "should return extended information of a given location" do
25
+ location = @client.location(514_276)
26
+ expect(location.name).to eq("Instagram")
27
+ end
28
+ end
29
+
30
+ describe ".location_recent_media" do
31
+ before do
32
+ stub_get("locations/514276/media/recent.#{format}")
33
+ .with(query: { access_token: @client.access_token })
34
+ .to_return(body: fixture("location_recent_media.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
35
+ end
36
+
37
+ it "should get the correct resource" do
38
+ @client.location_recent_media(514_276)
39
+ expect(a_get("locations/514276/media/recent.#{format}")
40
+ .with(query: { access_token: @client.access_token }))
41
+ .to have_been_made
42
+ end
43
+
44
+ it "should return a list of media taken at a given location" do
45
+ media = @client.location_recent_media(514_276)
46
+ expect(media).to be_a Array
47
+ expect(media.first.user.username).to eq("josh")
48
+ end
49
+ end
50
+
51
+ describe ".location_search_lat_lng" do
52
+ before do
53
+ stub_get("locations/search.#{format}")
54
+ .with(query: { access_token: @client.access_token })
55
+ .with(query: { lat: "37.7808851", lng: "-122.3948632" })
56
+ .to_return(body: fixture("location_search.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
57
+ end
58
+
59
+ it "should get the correct resource by lat/lng" do
60
+ @client.location_search("37.7808851", "-122.3948632")
61
+ expect(a_get("locations/search.#{format}")
62
+ .with(query: { access_token: @client.access_token })
63
+ .with(query: { lat: "37.7808851", lng: "-122.3948632" }))
64
+ .to have_been_made
65
+ end
66
+
67
+ it "should return an array of user search results" do
68
+ locations = @client.location_search("37.7808851", "-122.3948632")
69
+ expect(locations).to be_a Array
70
+ expect(locations.first.name).to eq("Instagram")
71
+ end
72
+ end
73
+
74
+ describe ".location_search_lat_lng_distance" do
75
+ before do
76
+ stub_get("locations/search.#{format}")
77
+ .with(query: { access_token: @client.access_token })
78
+ .with(query: { lat: "37.7808851", lng: "-122.3948632", distance: "5000" })
79
+ .to_return(body: fixture("location_search.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
80
+ end
81
+
82
+ it "should get the correct resource by lat/lng/distance" do
83
+ @client.location_search("37.7808851", "-122.3948632", "5000")
84
+ expect(a_get("locations/search.#{format}")
85
+ .with(query: { access_token: @client.access_token })
86
+ .with(query: { lat: "37.7808851", lng: "-122.3948632", distance: "5000" }))
87
+ .to have_been_made
88
+ end
89
+
90
+ it "should return an array of user search results" do
91
+ locations = @client.location_search("37.7808851", "-122.3948632", "5000")
92
+ expect(locations).to be_a Array
93
+ expect(locations.first.name).to eq("Instagram")
94
+ end
95
+ end
96
+
97
+ describe ".location_search_facebook_places_id" do
98
+ before do
99
+ stub_get("locations/search.#{format}")
100
+ .with(query: { access_token: @client.access_token })
101
+ .with(query: { facebook_places_id: "3fd66200f964a520c5f11ee3" })
102
+ .to_return(body: fixture("location_search_facebook.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
103
+ end
104
+
105
+ it "should get the correct resource by facebook_places_id" do
106
+ @client.location_search("3fd66200f964a520c5f11ee3")
107
+ expect(a_get("locations/search.#{format}")
108
+ .with(query: { access_token: @client.access_token })
109
+ .with(query: { facebook_places_id: "3fd66200f964a520c5f11ee3" }))
110
+ .to have_been_made
111
+ end
112
+
113
+ it "should return an array of user search results" do
114
+ locations = @client.location_search("3fd66200f964a520c5f11ee3")
115
+ expect(locations).to be_a Array
116
+ expect(locations.first.name).to eq("Schiller's Liquor Bar")
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,95 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ describe Instagram::Client do
4
+ Instagram::Configuration::VALID_FORMATS.each do |format|
5
+ context ".new(:format => '#{format}')" do
6
+ before do
7
+ @client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", access_token: "AT")
8
+ end
9
+
10
+ describe ".media_item" do
11
+ before do
12
+ stub_get("media/18600493.#{format}")
13
+ .with(query: { access_token: @client.access_token })
14
+ .to_return(body: fixture("media.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
15
+ end
16
+
17
+ it "should get the correct resource" do
18
+ @client.media_item(18_600_493)
19
+ expect(a_get("media/18600493.#{format}")
20
+ .with(query: { access_token: @client.access_token }))
21
+ .to have_been_made
22
+ end
23
+
24
+ it "should return extended information of a given media item" do
25
+ media = @client.media_item(18_600_493)
26
+ expect(media.user.username).to eq("mikeyk")
27
+ end
28
+ end
29
+
30
+ describe ".media_shortcode" do
31
+ before do
32
+ stub_get("media/shortcode/BG9It")
33
+ .with(query: { access_token: @client.access_token })
34
+ .to_return(body: fixture("media_shortcode.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
35
+ end
36
+
37
+ it "should get the correct resource" do
38
+ @client.media_shortcode("BG9It")
39
+ expect(a_get("media/shortcode/BG9It")
40
+ .with(query: { access_token: @client.access_token }))
41
+ .to have_been_made
42
+ end
43
+
44
+ it "should return extended information of a given media item" do
45
+ media = @client.media_shortcode("BG9It")
46
+ expect(media.user.username).to eq("mikeyk")
47
+ end
48
+ end
49
+
50
+ describe ".media_popular" do
51
+ before do
52
+ stub_get("media/popular.#{format}")
53
+ .with(query: { access_token: @client.access_token })
54
+ .to_return(body: fixture("media_popular.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
55
+ end
56
+
57
+ it "should get the correct resource" do
58
+ @client.media_popular
59
+ expect(a_get("media/popular.#{format}")
60
+ .with(query: { access_token: @client.access_token }))
61
+ .to have_been_made
62
+ end
63
+
64
+ it "should return popular media items" do
65
+ media_popular = @client.media_popular
66
+ expect(media_popular).to be_a Array
67
+ media_popular.first.user.username == "babycamera"
68
+ end
69
+ end
70
+
71
+ describe ".media_search" do
72
+ before do
73
+ stub_get("media/search.#{format}")
74
+ .with(query: { access_token: @client.access_token })
75
+ .with(query: { lat: "37.7808851", lng: "-122.3948632" })
76
+ .to_return(body: fixture("media_search.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
77
+ end
78
+
79
+ it "should get the correct resource" do
80
+ @client.media_search("37.7808851", "-122.3948632")
81
+ expect(a_get("media/search.#{format}")
82
+ .with(query: { access_token: @client.access_token })
83
+ .with(query: { lat: "37.7808851", lng: "-122.3948632" }))
84
+ .to have_been_made
85
+ end
86
+
87
+ it "should return an array of user search results" do
88
+ media_search = @client.media_search("37.7808851", "-122.3948632")
89
+ expect(media_search).to be_a Array
90
+ expect(media_search.first.user.username).to eq("mikeyk")
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,162 @@
1
+ require File.expand_path("../../../spec_helper", __FILE__)
2
+
3
+ describe Instagram::Client do
4
+ Instagram::Configuration::VALID_FORMATS.each do |format|
5
+ context ".new(:format => '#{format}')" do
6
+ before do
7
+ @client = Instagram::Client.new(format: format, client_id: "CID", client_secret: "CS", access_token: "AT")
8
+ end
9
+
10
+ describe ".subscriptions" do
11
+ before do
12
+ stub_get("subscriptions.#{format}")
13
+ .with(query: { client_id: @client.client_id, client_secret: @client.client_secret })
14
+ .to_return(body: fixture("subscriptions.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
15
+ end
16
+
17
+ it "should get the correct resource" do
18
+ @client.subscriptions
19
+ expect(a_get("subscriptions.#{format}")
20
+ .with(query: { client_id: @client.client_id, client_secret: @client.client_secret }))
21
+ .to have_been_made
22
+ end
23
+
24
+ it "should return an array of subscriptions" do
25
+ subscriptions = @client.subscriptions
26
+ expect(subscriptions).to be_a Array
27
+ expect(subscriptions.first.object).to eq("user")
28
+ end
29
+ end
30
+
31
+ describe ".create_subscription" do
32
+ before do
33
+ stub_post("subscriptions.#{format}")
34
+ .with(body: { object: "user", callback_url: "http://example.com/instagram/callback", aspect: "media", client_id: @client.client_id, client_secret: @client.client_secret })
35
+ .to_return(body: fixture("subscription.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
36
+ end
37
+
38
+ it "should get the correct resource" do
39
+ @client.create_subscription("user", callback_url: "http://example.com/instagram/callback")
40
+ expect(a_post("subscriptions.#{format}")
41
+ .with(body: { object: "user", callback_url: "http://example.com/instagram/callback", aspect: "media", client_id: @client.client_id, client_secret: @client.client_secret }))
42
+ .to have_been_made
43
+ end
44
+
45
+ it "should return the new subscription when successful" do
46
+ subscription = @client.create_subscription("user", callback_url: "http://example.com/instagram/callback")
47
+ expect(subscription.object).to eq("user")
48
+ end
49
+ end
50
+
51
+ describe ".delete_media_comment" do
52
+ before do
53
+ stub_delete("subscriptions.#{format}")
54
+ .with(query: { object: "user", client_id: @client.client_id, client_secret: @client.client_secret })
55
+ .to_return(body: fixture("subscription_deleted.#{format}"), headers: { content_type: "application/#{format}; charset=utf-8" })
56
+ end
57
+
58
+ it "should get the correct resource" do
59
+ @client.delete_subscription(object: "user")
60
+ expect(a_delete("subscriptions.#{format}")
61
+ .with(query: { object: "user", client_id: @client.client_id, client_secret: @client.client_secret }))
62
+ .to have_been_made
63
+ end
64
+ end
65
+
66
+ describe ".validate_update" do
67
+ subject { @client.validate_update(body, headers) }
68
+
69
+ context "when calculated signature matches request signature" do
70
+ let(:body) { { foo: "bar" }.to_json }
71
+ let(:request_signature) { OpenSSL::HMAC.hexdigest("sha1", @client.client_secret, body) }
72
+ let(:headers) { { "X-Hub-Signature" => request_signature } }
73
+
74
+ it { expect(subject).to be_truthy }
75
+ end
76
+
77
+ context "when calculated signature does not match request signature" do
78
+ let(:body) { { foo: "bar" }.to_json }
79
+ let(:request_signature) { "going to fail" }
80
+ let(:headers) { { "X-Hub-Signature" => request_signature } }
81
+
82
+ it { expect(subject).to be_falsey }
83
+ end
84
+ end
85
+
86
+ describe ".process_subscriptions" do
87
+ context "without a callbacks block" do
88
+ it "should raise an ArgumentError" do
89
+ expect do
90
+ @client.process_subscription(nil)
91
+ end.to raise_error(ArgumentError)
92
+ end
93
+ end
94
+
95
+ context "with a callbacks block and valid JSON" do
96
+ before do
97
+ @json = fixture("subscription_payload.json").read
98
+ end
99
+
100
+ it "should issue a callback to on_user_changed" do
101
+ @client.process_subscription(@json) do |handler|
102
+ handler.on_user_changed do |user_id, _payload|
103
+ expect(user_id).to eq("1234")
104
+ end
105
+ end
106
+ end
107
+
108
+ it "should issue a callback to on_tag_changed" do
109
+ @client.process_subscription(@json) do |handler|
110
+ handler.on_tag_changed do |tag_name, _payload|
111
+ expect(tag_name).to eq("nofilter")
112
+ end
113
+ end
114
+ end
115
+
116
+ it "should issue both callbacks in one block" do
117
+ @client.process_subscription(@json) do |handler|
118
+ handler.on_user_changed do |user_id, _payload|
119
+ expect(user_id).to eq("1234")
120
+ end
121
+
122
+ handler.on_tag_changed do |tag_name, _payload|
123
+ expect(tag_name).to eq("nofilter")
124
+ end
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ context "with a valid signature" do
131
+ before do
132
+ @json = fixture("subscription_payload.json").read
133
+ end
134
+
135
+ it "should not raise an Instagram::InvalidSignature error" do
136
+ expect do
137
+ @client.process_subscription(@json, signature: "f1dbe2b6184ac2131209c87bba8e0382d089a8a2") do |handler|
138
+ # hi
139
+ end
140
+ end.not_to raise_error
141
+ end
142
+ end
143
+
144
+ context "with an invalid signature" do
145
+ before do
146
+ @json = fixture("subscription_payload.json").read
147
+ end
148
+
149
+ it "should raise an Instagram::InvalidSignature error" do
150
+ invalid_signatures = ["31337H4X0R", nil]
151
+ invalid_signatures.each do |signature|
152
+ expect do
153
+ @client.process_subscription(@json, signature: signature) do |handler|
154
+ # hi
155
+ end
156
+ end.to raise_error(Instagram::InvalidSignature)
157
+ end
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end