-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from ruby-oembed/feature/per-provider-specs
per-Provider specs
- Loading branch information
Showing
8 changed files
with
1,733 additions
and
14 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require File.join(File.dirname(__FILE__), '../spec_helper') | ||
require 'support/shared_examples_for_providers' | ||
|
||
describe 'OEmbed::Providers::Slideshare' do | ||
before(:all) do | ||
VCR.insert_cassette('OEmbed_Providers_Slideshare') | ||
end | ||
after(:all) do | ||
VCR.eject_cassette | ||
end | ||
|
||
include OEmbedSpecHelper | ||
|
||
let(:provider_class) { OEmbed::Providers::Slideshare } | ||
|
||
expected_valid_urls = ( | ||
%w(https:// http://).map do |protocol| | ||
%w(slideshare.net www.slideshare.net de.slideshare.net).map do |host| | ||
[ | ||
'/gabriele.lana/the-magic-of-elixir', | ||
# Even though Slideshare's oEmbed endpoint | ||
# is supposed to /mobile/ URLs, | ||
# as of 2016-05-21 it's returning 404 results for these URLs. | ||
#'/mobile/gabriele.lana/the-magic-of-elixir', | ||
].map do |path| | ||
File.join(protocol, host, path) | ||
end | ||
end | ||
end | ||
).flatten | ||
|
||
expected_invalid_urls = %w( | ||
http://www.slideshare.net | ||
http://www.slideshare.net/gabriele.lana | ||
) | ||
|
||
it_should_behave_like( | ||
"an OEmbed::Proviers instance", | ||
expected_valid_urls, | ||
expected_invalid_urls | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require File.join(File.dirname(__FILE__), '../spec_helper') | ||
require 'support/shared_examples_for_providers' | ||
|
||
describe 'OEmbed::Providers::Twitter' do | ||
before(:all) do | ||
VCR.insert_cassette('OEmbed_Providers_Twitter') | ||
end | ||
after(:all) do | ||
VCR.eject_cassette | ||
end | ||
|
||
include OEmbedSpecHelper | ||
|
||
let(:provider_class) { OEmbed::Providers::Twitter } | ||
|
||
expected_valid_urls = %w( | ||
https://twitter.com/RailsGirlsSoC/status/702136612822634496 | ||
https://www.twitter.com/bpoweski/status/71633762 | ||
) | ||
expected_invalid_urls = %w( | ||
http://twitter.com/RailsGirlsSoC/status/702136612822634496 | ||
https://twitter.es/FCBarcelona_es/status/734194638697959424 | ||
) | ||
|
||
it_should_behave_like( | ||
"an OEmbed::Proviers instance", | ||
expected_valid_urls, | ||
expected_invalid_urls | ||
) | ||
|
||
context "using XML" do | ||
expected_valid_urls.each do |valid_url| | ||
context "given the valid URL #{valid_url}" do | ||
describe ".get" do | ||
it "should encounter a 400 error" do | ||
expect { | ||
provider_class.get(valid_url, :format=>:xml) | ||
}.to raise_error(OEmbed::UnknownResponse, /\b400\b/) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
RSpec.shared_examples "an OEmbed::Proviers instance" do |expected_valid_urls, expected_invalid_urls| | ||
expected_valid_urls.each do |valid_url| | ||
context "given the valid URL #{valid_url}" do | ||
describe ".include?" do | ||
it "should be true" do | ||
expect(provider_class.include?(valid_url)).to be_truthy | ||
end | ||
end | ||
|
||
describe ".get" do | ||
it "should return a response" do | ||
response = nil | ||
expect { | ||
response = provider_class.get(valid_url) | ||
}.to_not raise_error | ||
expect(response).to be_a(OEmbed::Response) | ||
end | ||
end | ||
end | ||
end | ||
|
||
expected_invalid_urls.each do |invalid_url| | ||
context "given the invalid URL #{invalid_url}" do | ||
describe ".include?" do | ||
it "should be false" do | ||
expect(provider_class.include?(invalid_url)).to be_falsey | ||
end | ||
end | ||
|
||
describe ".get" do | ||
it "should not find a response" do | ||
expect { | ||
provider_class.get(invalid_url) | ||
}.to raise_error(OEmbed::NotFound) | ||
end | ||
end | ||
end | ||
end | ||
end |