File tree Expand file tree Collapse file tree 8 files changed +1733
-14
lines changed Expand file tree Collapse file tree 8 files changed +1733
-14
lines changed Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 1
1
require File . dirname ( __FILE__ ) + '/spec_helper'
2
2
require 'json'
3
- require 'vcr'
4
-
5
- VCR . config do |c |
6
- c . default_cassette_options = { :record => :new_episodes }
7
- c . cassette_library_dir = 'spec/cassettes'
8
- c . stub_with :fakeweb
9
- end
10
3
11
4
describe OEmbed ::ProviderDiscovery do
12
5
before ( :all ) do
Original file line number Diff line number Diff line change 1
1
require File . dirname ( __FILE__ ) + '/spec_helper'
2
- require 'vcr'
3
-
4
- VCR . config do |c |
5
- c . default_cassette_options = { :record => :new_episodes }
6
- c . cassette_library_dir = 'spec/cassettes'
7
- c . stub_with :fakeweb
8
- end
9
2
10
3
describe OEmbed ::Provider do
11
4
before ( :all ) do
Original file line number Diff line number Diff line change
1
+ require File . join ( File . dirname ( __FILE__ ) , '../spec_helper' )
2
+ require 'support/shared_examples_for_providers'
3
+
4
+ describe 'OEmbed::Providers::Slideshare' do
5
+ before ( :all ) do
6
+ VCR . insert_cassette ( 'OEmbed_Providers_Slideshare' )
7
+ end
8
+ after ( :all ) do
9
+ VCR . eject_cassette
10
+ end
11
+
12
+ include OEmbedSpecHelper
13
+
14
+ let ( :provider_class ) { OEmbed ::Providers ::Slideshare }
15
+
16
+ expected_valid_urls = (
17
+ %w( https:// http:// ) . map do |protocol |
18
+ %w( slideshare.net www.slideshare.net de.slideshare.net ) . map do |host |
19
+ [
20
+ '/gabriele.lana/the-magic-of-elixir' ,
21
+ # Even though Slideshare's oEmbed endpoint
22
+ # is supposed to /mobile/ URLs,
23
+ # as of 2016-05-21 it's returning 404 results for these URLs.
24
+ #'/mobile/gabriele.lana/the-magic-of-elixir',
25
+ ] . map do |path |
26
+ File . join ( protocol , host , path )
27
+ end
28
+ end
29
+ end
30
+ ) . flatten
31
+
32
+ expected_invalid_urls = %w(
33
+ http://www.slideshare.net
34
+ http://www.slideshare.net/gabriele.lana
35
+ )
36
+
37
+ it_should_behave_like (
38
+ "an OEmbed::Proviers instance" ,
39
+ expected_valid_urls ,
40
+ expected_invalid_urls
41
+ )
42
+ end
Original file line number Diff line number Diff line change
1
+ require File . join ( File . dirname ( __FILE__ ) , '../spec_helper' )
2
+ require 'support/shared_examples_for_providers'
3
+
4
+ describe 'OEmbed::Providers::Twitter' do
5
+ before ( :all ) do
6
+ VCR . insert_cassette ( 'OEmbed_Providers_Twitter' )
7
+ end
8
+ after ( :all ) do
9
+ VCR . eject_cassette
10
+ end
11
+
12
+ include OEmbedSpecHelper
13
+
14
+ let ( :provider_class ) { OEmbed ::Providers ::Twitter }
15
+
16
+ expected_valid_urls = %w(
17
+ https://twitter.com/RailsGirlsSoC/status/702136612822634496
18
+ https://www.twitter.com/bpoweski/status/71633762
19
+ )
20
+ expected_invalid_urls = %w(
21
+ http://twitter.com/RailsGirlsSoC/status/702136612822634496
22
+ https://twitter.es/FCBarcelona_es/status/734194638697959424
23
+ )
24
+
25
+ it_should_behave_like (
26
+ "an OEmbed::Proviers instance" ,
27
+ expected_valid_urls ,
28
+ expected_invalid_urls
29
+ )
30
+
31
+ context "using XML" do
32
+ expected_valid_urls . each do |valid_url |
33
+ context "given the valid URL #{ valid_url } " do
34
+ describe ".get" do
35
+ it "should encounter a 400 error" do
36
+ expect {
37
+ provider_class . get ( valid_url , :format => :xml )
38
+ } . to raise_error ( OEmbed ::UnknownResponse , /\b 400\b / )
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
Original file line number Diff line number Diff line change 1
1
require 'rubygems'
2
+
2
3
require 'vcr'
4
+ VCR . config do |c |
5
+ c . default_cassette_options = { :record => :new_episodes }
6
+ c . cassette_library_dir = 'spec/cassettes'
7
+ c . stub_with :fakeweb
8
+ end
3
9
4
10
require 'coveralls'
5
11
Coveralls . wear!
Original file line number Diff line number Diff line change
1
+ RSpec . shared_examples "an OEmbed::Proviers instance" do |expected_valid_urls , expected_invalid_urls |
2
+ expected_valid_urls . each do |valid_url |
3
+ context "given the valid URL #{ valid_url } " do
4
+ describe ".include?" do
5
+ it "should be true" do
6
+ expect ( provider_class . include? ( valid_url ) ) . to be_truthy
7
+ end
8
+ end
9
+
10
+ describe ".get" do
11
+ it "should return a response" do
12
+ response = nil
13
+ expect {
14
+ response = provider_class . get ( valid_url )
15
+ } . to_not raise_error
16
+ expect ( response ) . to be_a ( OEmbed ::Response )
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ expected_invalid_urls . each do |invalid_url |
23
+ context "given the invalid URL #{ invalid_url } " do
24
+ describe ".include?" do
25
+ it "should be false" do
26
+ expect ( provider_class . include? ( invalid_url ) ) . to be_falsey
27
+ end
28
+ end
29
+
30
+ describe ".get" do
31
+ it "should not find a response" do
32
+ expect {
33
+ provider_class . get ( invalid_url )
34
+ } . to raise_error ( OEmbed ::NotFound )
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
You can’t perform that action at this time.
0 commit comments