ruby-oembed 0.11.0 → 0.14.1
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.
- checksums.yaml +5 -5
- data/.gitignore +11 -2
- data/.travis.yml +3 -6
- data/CHANGELOG.rdoc +27 -1
- data/Gemfile +10 -10
- data/README.md +45 -13
- data/Rakefile +2 -0
- data/lib/oembed/providers.rb +36 -34
- data/lib/oembed/providers/{embedly_urls.yml → aggregators/embedly_urls.yml} +934 -281
- data/lib/oembed/providers/aggregators/noembed_urls.yml +321 -0
- data/lib/oembed/providers/{oohembed_urls.yml → aggregators/oohembed_urls.yml} +0 -0
- data/lib/oembed/providers/facebook_post.rb +25 -0
- data/lib/oembed/providers/facebook_video.rb +18 -0
- data/lib/oembed/providers/instagram.rb +28 -0
- data/lib/oembed/version.rb +2 -2
- data/lib/tasks/oembed.rake +24 -23
- data/ruby-oembed.gemspec +2 -29
- data/spec/cassettes/OEmbed_Provider.yml +882 -119
- data/spec/cassettes/OEmbed_ProviderDiscovery.yml +26007 -35598
- data/spec/cassettes/OEmbed_Providers_Slideshare.yml +1024 -790
- data/spec/cassettes/OEmbed_Providers_Twitter.yml +447 -238
- data/spec/cassettes/OEmbed_Providers_Youtube.yml +211 -0
- data/spec/provider_discovery_spec.rb +2 -7
- data/spec/provider_spec.rb +67 -74
- data/spec/providers/facebook_spec.rb +50 -0
- data/spec/providers/slideshare_spec.rb +1 -1
- data/spec/providers/twitter_spec.rb +1 -1
- data/spec/providers/youtube_spec.rb +42 -0
- data/spec/providers_spec.rb +48 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/spec_helper_examples.yml +6 -16
- data/spec/support/shared_examples_for_providers.rb +1 -1
- metadata +17 -78
@@ -0,0 +1,211 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://www.youtube.com/oembed/?format=json&scheme=https&url=https://www.youtube.com/watch?v=pO5L6vXtxsI
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept-Encoding:
|
11
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
12
|
+
Accept:
|
13
|
+
- "*/*"
|
14
|
+
User-Agent:
|
15
|
+
- Mozilla/5.0 (compatible; ruby-oembed/0.14.0)
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Strict-Transport-Security:
|
22
|
+
- max-age=31536000
|
23
|
+
Cache-Control:
|
24
|
+
- no-cache
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
P3p:
|
28
|
+
- CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en
|
29
|
+
for more info."
|
30
|
+
Expires:
|
31
|
+
- Tue, 27 Apr 1971 19:44:06 GMT
|
32
|
+
X-Content-Type-Options:
|
33
|
+
- nosniff
|
34
|
+
Date:
|
35
|
+
- Mon, 28 Dec 2020 15:32:04 GMT
|
36
|
+
Server:
|
37
|
+
- YouTube Frontend Proxy
|
38
|
+
X-Xss-Protection:
|
39
|
+
- '0'
|
40
|
+
Alt-Svc:
|
41
|
+
- h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443";
|
42
|
+
ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
|
43
|
+
Accept-Ranges:
|
44
|
+
- none
|
45
|
+
Vary:
|
46
|
+
- Accept-Encoding
|
47
|
+
Transfer-Encoding:
|
48
|
+
- chunked
|
49
|
+
body:
|
50
|
+
encoding: UTF-8
|
51
|
+
string: '{"title":"CKEditor 4.5 - Embedding Media Resources with oEmbed","author_name":"CKEditor
|
52
|
+
Ecosystem","author_url":"https://www.youtube.com/c/CKEditor","type":"video","height":270,"width":480,"version":"1.0","provider_name":"YouTube","provider_url":"https://www.youtube.com/","thumbnail_height":360,"thumbnail_width":480,"thumbnail_url":"https://i.ytimg.com/vi/pO5L6vXtxsI/hqdefault.jpg","html":"\u003ciframe
|
53
|
+
width=\u0022480\u0022 height=\u0022270\u0022 src=\u0022https://www.youtube.com/embed/pO5L6vXtxsI?feature=oembed\u0022
|
54
|
+
frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write;
|
55
|
+
encrypted-media; gyroscope; picture-in-picture\u0022 allowfullscreen\u003e\u003c/iframe\u003e"}'
|
56
|
+
recorded_at: Mon, 28 Dec 2020 15:32:04 GMT
|
57
|
+
- request:
|
58
|
+
method: get
|
59
|
+
uri: https://www.youtube.com/oembed/?format=json&scheme=https&url=http://www.youtube.com/watch?v=pO5L6vXtxsI
|
60
|
+
body:
|
61
|
+
encoding: US-ASCII
|
62
|
+
string: ''
|
63
|
+
headers:
|
64
|
+
Accept-Encoding:
|
65
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
66
|
+
Accept:
|
67
|
+
- "*/*"
|
68
|
+
User-Agent:
|
69
|
+
- Mozilla/5.0 (compatible; ruby-oembed/0.14.0)
|
70
|
+
response:
|
71
|
+
status:
|
72
|
+
code: 200
|
73
|
+
message: OK
|
74
|
+
headers:
|
75
|
+
P3p:
|
76
|
+
- CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en
|
77
|
+
for more info."
|
78
|
+
Cache-Control:
|
79
|
+
- no-cache
|
80
|
+
Content-Type:
|
81
|
+
- application/json
|
82
|
+
Strict-Transport-Security:
|
83
|
+
- max-age=31536000
|
84
|
+
Expires:
|
85
|
+
- Tue, 27 Apr 1971 19:44:06 GMT
|
86
|
+
X-Content-Type-Options:
|
87
|
+
- nosniff
|
88
|
+
Date:
|
89
|
+
- Mon, 28 Dec 2020 15:32:04 GMT
|
90
|
+
Server:
|
91
|
+
- YouTube Frontend Proxy
|
92
|
+
X-Xss-Protection:
|
93
|
+
- '0'
|
94
|
+
Alt-Svc:
|
95
|
+
- h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443";
|
96
|
+
ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
|
97
|
+
Accept-Ranges:
|
98
|
+
- none
|
99
|
+
Vary:
|
100
|
+
- Accept-Encoding
|
101
|
+
Transfer-Encoding:
|
102
|
+
- chunked
|
103
|
+
body:
|
104
|
+
encoding: UTF-8
|
105
|
+
string: '{"title":"CKEditor 4.5 - Embedding Media Resources with oEmbed","author_name":"CKEditor
|
106
|
+
Ecosystem","author_url":"https://www.youtube.com/c/CKEditor","type":"video","height":270,"width":480,"version":"1.0","provider_name":"YouTube","provider_url":"https://www.youtube.com/","thumbnail_height":360,"thumbnail_width":480,"thumbnail_url":"https://i.ytimg.com/vi/pO5L6vXtxsI/hqdefault.jpg","html":"\u003ciframe
|
107
|
+
width=\u0022480\u0022 height=\u0022270\u0022 src=\u0022https://www.youtube.com/embed/pO5L6vXtxsI?feature=oembed\u0022
|
108
|
+
frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write;
|
109
|
+
encrypted-media; gyroscope; picture-in-picture\u0022 allowfullscreen\u003e\u003c/iframe\u003e"}'
|
110
|
+
recorded_at: Mon, 28 Dec 2020 15:32:04 GMT
|
111
|
+
- request:
|
112
|
+
method: get
|
113
|
+
uri: https://www.youtube.com/oembed/?format=json&scheme=https&url=https://youtu.be/pO5L6vXtxsI
|
114
|
+
body:
|
115
|
+
encoding: US-ASCII
|
116
|
+
string: ''
|
117
|
+
headers:
|
118
|
+
Accept-Encoding:
|
119
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
120
|
+
Accept:
|
121
|
+
- "*/*"
|
122
|
+
User-Agent:
|
123
|
+
- Mozilla/5.0 (compatible; ruby-oembed/0.14.0)
|
124
|
+
response:
|
125
|
+
status:
|
126
|
+
code: 200
|
127
|
+
message: OK
|
128
|
+
headers:
|
129
|
+
Expires:
|
130
|
+
- Tue, 27 Apr 1971 19:44:06 GMT
|
131
|
+
P3p:
|
132
|
+
- CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en
|
133
|
+
for more info."
|
134
|
+
Content-Type:
|
135
|
+
- application/json
|
136
|
+
Cache-Control:
|
137
|
+
- no-cache
|
138
|
+
X-Content-Type-Options:
|
139
|
+
- nosniff
|
140
|
+
Strict-Transport-Security:
|
141
|
+
- max-age=31536000
|
142
|
+
Date:
|
143
|
+
- Mon, 28 Dec 2020 15:32:04 GMT
|
144
|
+
Server:
|
145
|
+
- YouTube Frontend Proxy
|
146
|
+
X-Xss-Protection:
|
147
|
+
- '0'
|
148
|
+
Alt-Svc:
|
149
|
+
- h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443";
|
150
|
+
ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
|
151
|
+
Accept-Ranges:
|
152
|
+
- none
|
153
|
+
Vary:
|
154
|
+
- Accept-Encoding
|
155
|
+
Transfer-Encoding:
|
156
|
+
- chunked
|
157
|
+
body:
|
158
|
+
encoding: UTF-8
|
159
|
+
string: '{"title":"CKEditor 4.5 - Embedding Media Resources with oEmbed","author_name":"CKEditor
|
160
|
+
Ecosystem","author_url":"https://www.youtube.com/c/CKEditor","type":"video","height":270,"width":480,"version":"1.0","provider_name":"YouTube","provider_url":"https://www.youtube.com/","thumbnail_height":360,"thumbnail_width":480,"thumbnail_url":"https://i.ytimg.com/vi/pO5L6vXtxsI/hqdefault.jpg","html":"\u003ciframe
|
161
|
+
width=\u0022480\u0022 height=\u0022270\u0022 src=\u0022https://www.youtube.com/embed/pO5L6vXtxsI?feature=oembed\u0022
|
162
|
+
frameborder=\u00220\u0022 allow=\u0022accelerometer; autoplay; clipboard-write;
|
163
|
+
encrypted-media; gyroscope; picture-in-picture\u0022 allowfullscreen\u003e\u003c/iframe\u003e"}'
|
164
|
+
recorded_at: Mon, 28 Dec 2020 15:32:04 GMT
|
165
|
+
- request:
|
166
|
+
method: get
|
167
|
+
uri: https://www.youtube.com/oembed/?format=json&scheme=https&url=https://youtu.be/NHriYTkvd0g
|
168
|
+
body:
|
169
|
+
encoding: US-ASCII
|
170
|
+
string: ''
|
171
|
+
headers:
|
172
|
+
Accept-Encoding:
|
173
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
174
|
+
Accept:
|
175
|
+
- "*/*"
|
176
|
+
User-Agent:
|
177
|
+
- Mozilla/5.0 (compatible; ruby-oembed/0.14.0)
|
178
|
+
response:
|
179
|
+
status:
|
180
|
+
code: 403
|
181
|
+
message: Forbidden
|
182
|
+
headers:
|
183
|
+
Strict-Transport-Security:
|
184
|
+
- max-age=31536000
|
185
|
+
Content-Length:
|
186
|
+
- '9'
|
187
|
+
X-Content-Type-Options:
|
188
|
+
- nosniff
|
189
|
+
Content-Type:
|
190
|
+
- text/html; charset=utf-8
|
191
|
+
Cache-Control:
|
192
|
+
- no-cache
|
193
|
+
P3p:
|
194
|
+
- CP="This is not a P3P policy! See http://support.google.com/accounts/answer/151657?hl=en
|
195
|
+
for more info."
|
196
|
+
Expires:
|
197
|
+
- Tue, 27 Apr 1971 19:44:06 GMT
|
198
|
+
Date:
|
199
|
+
- Mon, 28 Dec 2020 15:32:04 GMT
|
200
|
+
Server:
|
201
|
+
- YouTube Frontend Proxy
|
202
|
+
X-Xss-Protection:
|
203
|
+
- '0'
|
204
|
+
Alt-Svc:
|
205
|
+
- h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443";
|
206
|
+
ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
|
207
|
+
body:
|
208
|
+
encoding: UTF-8
|
209
|
+
string: Forbidden
|
210
|
+
recorded_at: Mon, 28 Dec 2020 15:32:04 GMT
|
211
|
+
recorded_with: VCR 6.0.0
|
@@ -24,8 +24,8 @@ describe OEmbed::ProviderDiscovery do
|
|
24
24
|
:json,
|
25
25
|
],
|
26
26
|
'vimeo' => [
|
27
|
-
'
|
28
|
-
{:json=>'
|
27
|
+
'https://vimeo.com/27953845',
|
28
|
+
{:json=>'https://vimeo.com/api/oembed.json', :xml=>'https://vimeo.com/api/oembed.xml'},
|
29
29
|
:json,
|
30
30
|
],
|
31
31
|
'facebook-photo' => [
|
@@ -38,11 +38,6 @@ describe OEmbed::ProviderDiscovery do
|
|
38
38
|
'https://www.tumblr.com/oembed/1.0',
|
39
39
|
:json
|
40
40
|
],
|
41
|
-
'noteflight' => [
|
42
|
-
'http://www.noteflight.com/scores/view/09665392c94475f65dfaf5f30aadb6ed0921939d',
|
43
|
-
{:json=>'http://www.noteflight.com/services/oembed', :xml=>'http://www.noteflight.com/services/oembed'},
|
44
|
-
:json,
|
45
|
-
],
|
46
41
|
# TODO: Enhance ProviderDiscovery to support arbitrary query parameters. See https://github.com/ruby-oembed/ruby-oembed/issues/15
|
47
42
|
#'wordpress' => [
|
48
43
|
# 'http://sweetandweak.wordpress.com/2011/09/23/nothing-starts-the-morning-like-a-good-dose-of-panic/',
|
data/spec/provider_spec.rb
CHANGED
@@ -49,108 +49,108 @@ describe OEmbed::Provider do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should allow no URI schema to be given" do
|
52
|
-
|
53
|
-
|
54
|
-
expect(
|
55
|
-
expect(
|
56
|
-
expect(
|
57
|
-
expect(
|
58
|
-
expect(
|
59
|
-
expect(
|
52
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
53
|
+
|
54
|
+
expect(provider).to include("http://foo.com/1")
|
55
|
+
expect(provider).to include("http://bar.foo.com/1")
|
56
|
+
expect(provider).to include("http://bar.foo.com/show/1")
|
57
|
+
expect(provider).to include("https://bar.foo.com/1")
|
58
|
+
expect(provider).to include("http://asdf.com/1")
|
59
|
+
expect(provider).to include("asdf")
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should allow a String as a URI schema" do
|
63
|
-
|
64
|
-
|
63
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
64
|
+
provider << "http://bar.foo.com/*"
|
65
65
|
|
66
|
-
expect(
|
67
|
-
expect(
|
66
|
+
expect(provider).to include("http://bar.foo.com/1")
|
67
|
+
expect(provider).to include("http://bar.foo.com/show/1")
|
68
68
|
|
69
|
-
expect(
|
70
|
-
expect(
|
69
|
+
expect(provider).to_not include("https://bar.foo.com/1")
|
70
|
+
expect(provider).to_not include("http://foo.com/1")
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should allow multiple path wildcards in a String URI schema" do
|
74
|
-
|
75
|
-
|
74
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
75
|
+
provider << "http://bar.foo.com/*/show/*"
|
76
76
|
|
77
|
-
expect(
|
78
|
-
expect(
|
79
|
-
expect(
|
77
|
+
expect(provider).to include("http://bar.foo.com/photo/show/1")
|
78
|
+
expect(provider).to include("http://bar.foo.com/video/show/2")
|
79
|
+
expect(provider).to include("http://bar.foo.com/help/video/show/2")
|
80
80
|
|
81
|
-
expect(
|
82
|
-
expect(
|
83
|
-
expect(
|
84
|
-
expect(
|
81
|
+
expect(provider).to_not include("https://bar.foo.com/photo/show/1")
|
82
|
+
expect(provider).to_not include("http://foo.com/video/show/2")
|
83
|
+
expect(provider).to_not include("http://bar.foo.com/show/1")
|
84
|
+
expect(provider).to_not include("http://bar.foo.com/1")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "should NOT allow multiple domain wildcards in a String URI schema", :pending => true do
|
88
|
-
|
88
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
89
89
|
|
90
|
-
expect {
|
90
|
+
expect { provider << "http://*.com/*" }.
|
91
91
|
to raise_error(ArgumentError)
|
92
92
|
|
93
|
-
expect(
|
93
|
+
expect(provider).to_not include("http://foo.com/1")
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should allow a sub-domain wildcard in String URI schema" do
|
97
|
-
|
98
|
-
|
97
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
98
|
+
provider << "http://*.foo.com/*"
|
99
99
|
|
100
|
-
expect(
|
101
|
-
expect(
|
102
|
-
expect(
|
100
|
+
expect(provider).to include("http://bar.foo.com/1")
|
101
|
+
expect(provider).to include("http://foo.foo.com/2")
|
102
|
+
expect(provider).to include("http://foo.com/3")
|
103
103
|
|
104
|
-
expect(
|
105
|
-
expect(
|
104
|
+
expect(provider).to_not include("https://bar.foo.com/1")
|
105
|
+
expect(provider).to_not include("http://my.bar.foo.com/1")
|
106
106
|
|
107
|
-
|
107
|
+
provider << "http://my.*.foo.com/*"
|
108
108
|
end
|
109
109
|
|
110
110
|
it "should allow multiple sub-domain wildcards in a String URI schema" do
|
111
|
-
|
112
|
-
|
111
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
112
|
+
provider << "http://*.my.*.foo.com/*"
|
113
113
|
|
114
|
-
expect(
|
115
|
-
expect(
|
116
|
-
expect(
|
114
|
+
expect(provider).to include("http://my.bar.foo.com/1")
|
115
|
+
expect(provider).to include("http://my.foo.com/2")
|
116
|
+
expect(provider).to include("http://bar.my.bar.foo.com/3")
|
117
117
|
|
118
|
-
expect(
|
119
|
-
expect(
|
118
|
+
expect(provider).to_not include("http://bar.foo.com/1")
|
119
|
+
expect(provider).to_not include("http://foo.bar.foo.com/1")
|
120
120
|
end
|
121
121
|
|
122
122
|
it "should NOT allow a scheme wildcard in a String URI schema", :pending => true do
|
123
|
-
|
123
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
124
124
|
|
125
|
-
expect {
|
125
|
+
expect { provider << "*://foo.com/*" }.
|
126
126
|
to raise_error(ArgumentError)
|
127
127
|
|
128
|
-
expect(
|
128
|
+
expect(provider).to_not include("http://foo.com/1")
|
129
129
|
end
|
130
130
|
|
131
131
|
it "should allow a scheme other than http in a String URI schema" do
|
132
|
-
|
133
|
-
|
132
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
133
|
+
provider << "https://foo.com/*"
|
134
134
|
|
135
|
-
expect(
|
135
|
+
expect(provider).to include("https://foo.com/1")
|
136
136
|
|
137
137
|
gopher_url = "gopher://foo.com/1"
|
138
|
-
expect(
|
139
|
-
|
140
|
-
expect(
|
138
|
+
expect(provider).to_not include(gopher_url)
|
139
|
+
provider << "gopher://foo.com/*"
|
140
|
+
expect(provider).to include(gopher_url)
|
141
141
|
end
|
142
142
|
|
143
143
|
it "should allow a Regexp as a URI schema" do
|
144
|
-
|
145
|
-
|
144
|
+
provider = OEmbed::Provider.new("http://foo.com/oembed")
|
145
|
+
provider << %r{^https?://([^\.]*\.)?foo.com/(show/)?\d+}
|
146
146
|
|
147
|
-
expect(
|
148
|
-
expect(
|
149
|
-
expect(
|
150
|
-
expect(
|
147
|
+
expect(provider).to include("http://bar.foo.com/1")
|
148
|
+
expect(provider).to include("http://bar.foo.com/show/1")
|
149
|
+
expect(provider).to include("http://foo.com/1")
|
150
|
+
expect(provider).to include("https://bar.foo.com/1")
|
151
151
|
|
152
|
-
expect(
|
153
|
-
expect(
|
152
|
+
expect(provider).to_not include("http://bar.foo.com/video/1")
|
153
|
+
expect(provider).to_not include("gopher://foo.com/1")
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should by default use OEmbed::Formatter.default" do
|
@@ -267,37 +267,30 @@ describe OEmbed::Provider do
|
|
267
267
|
@vimeo_ssl << "http://*.vimeo.com/*"
|
268
268
|
@vimeo_ssl << "https://*.vimeo.com/*"
|
269
269
|
|
270
|
-
|
271
|
-
|
272
|
-
expect(res).to eq(example_body(:vimeo_ssl))
|
273
|
-
}.not_to raise_error
|
270
|
+
res = @vimeo_ssl.send(:raw, example_url(:vimeo_ssl))
|
271
|
+
expect(res).to eq(example_body(:vimeo_ssl).strip)
|
274
272
|
end
|
275
273
|
|
276
274
|
it "should raise an UnknownFormat error on 501" do
|
277
|
-
|
278
|
-
# cassettes/OEmbed_Provider.yml file.
|
275
|
+
stub_request(:get, /flickr/).to_return(status: 501)
|
279
276
|
|
280
277
|
expect {
|
281
|
-
@flickr.send(:raw, File.join(example_url(:flickr), '501'))
|
278
|
+
result = @flickr.send(:raw, File.join(example_url(:flickr), '501'))
|
282
279
|
}.to raise_error(OEmbed::UnknownFormat)
|
283
280
|
end
|
284
281
|
|
285
282
|
it "should raise a NotFound error on 404" do
|
286
|
-
|
287
|
-
# cassettes/OEmbed_Provider.yml file.
|
283
|
+
stub_request(:get, /flickr/).to_return(status: 404)
|
288
284
|
|
289
285
|
expect {
|
290
286
|
@flickr.send(:raw, File.join(example_url(:flickr), '404'))
|
291
287
|
}.to raise_error(OEmbed::NotFound)
|
292
288
|
end
|
293
289
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
statuses_to_check = ['405', '500']
|
290
|
+
['405', '500'].each do |status|
|
291
|
+
it "should raise an UnknownResponse error on other responses (#{status})" do
|
292
|
+
stub_request(:get, /flickr/).to_return(status: status)
|
299
293
|
|
300
|
-
statuses_to_check.each do |status|
|
301
294
|
expect {
|
302
295
|
@flickr.send(:raw, File.join(example_url(:flickr), status))
|
303
296
|
}.to raise_error(OEmbed::UnknownResponse)
|
@@ -364,7 +357,7 @@ describe OEmbed::Provider do
|
|
364
357
|
@viddler.get(example_url(:viddler))
|
365
358
|
end
|
366
359
|
|
367
|
-
it "handles the :timeout option" do
|
360
|
+
it "handles the :timeout option", pending: true do
|
368
361
|
expect_any_instance_of(Net::HTTP).to receive(:open_timeout=).with(5)
|
369
362
|
expect_any_instance_of(Net::HTTP).to receive(:read_timeout=).with(5)
|
370
363
|
@flickr.get(example_url(:flickr), :timeout => 5)
|