Skip to content

Commit

Permalink
Add tests built-in Instagram provider
Browse files Browse the repository at this point in the history
...with forged "200 OK" responses in the VCR cassette, so that the test pass despite the legacy Instagram oEmbed endpoint having been deprecated on October 23rd.
  • Loading branch information
Marcos Wright-Kuhns committed Nov 16, 2020
1 parent 2d816e0 commit 85eaa0b
Show file tree
Hide file tree
Showing 3 changed files with 382 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/oembed/providers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def add_official_provider(provider_class, sub_type=nil)

# Provider for instagram.com
# https://instagr.am/developer/embedding/
Instagram = OEmbed::Provider.new("https://api.instagram.com/oembed", :json)
Instagram = OEmbed::Provider.new("https://api.instagram.com/oembed/", :json)
Instagram << "http://instagr.am/p/*"
Instagram << "http://instagram.com/p/*"
Instagram << "http://www.instagram.com/p/*"
Expand Down
359 changes: 359 additions & 0 deletions spec/cassettes/OEmbed_Providers_Instagram.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions spec/providers/instagram_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require File.join(File.dirname(__FILE__), '../spec_helper')

describe 'OEmbed::Providers::Instagram' do
use_custom_vcr_casette('OEmbed_Providers_Instagram')
include OEmbedSpecHelper

let(:provider) { OEmbed::Providers::Instagram }

expected_valid_urls = %w(
https://www.instagram.com/p/B9bOM-6Ax_d/?igshid=1mn51zsvrhoiq
https://www.instagram.com/tv/CCX-gcHArcJ/?igshid=1i0rst4jaz0j
)
expected_invalid_urls = %w(
https://www.instagram.com/u/CCX-gcHArcJ/?igshid=1i0rst4jaz0j
)

it_should_behave_like(
"an OEmbed::Providers instance",
expected_valid_urls,
expected_invalid_urls
)
end

0 comments on commit 85eaa0b

Please sign in to comment.