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.
@@ -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
- 'http://vimeo.com/27953845',
28
- {:json=>'http://vimeo.com/api/oembed.json', :xml=>'http://vimeo.com/api/oembed.xml'},
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/',
@@ -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
- provier = OEmbed::Provider.new("http://foo.com/oembed")
53
-
54
- expect(provier).to include("http://foo.com/1")
55
- expect(provier).to include("http://bar.foo.com/1")
56
- expect(provier).to include("http://bar.foo.com/show/1")
57
- expect(provier).to include("https://bar.foo.com/1")
58
- expect(provier).to include("http://asdf.com/1")
59
- expect(provier).to include("asdf")
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
- provier = OEmbed::Provider.new("http://foo.com/oembed")
64
- provier << "http://bar.foo.com/*"
63
+ provider = OEmbed::Provider.new("http://foo.com/oembed")
64
+ provider << "http://bar.foo.com/*"
65
65
 
66
- expect(provier).to include("http://bar.foo.com/1")
67
- expect(provier).to include("http://bar.foo.com/show/1")
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(provier).to_not include("https://bar.foo.com/1")
70
- expect(provier).to_not include("http://foo.com/1")
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
- provier = OEmbed::Provider.new("http://foo.com/oembed")
75
- provier << "http://bar.foo.com/*/show/*"
74
+ provider = OEmbed::Provider.new("http://foo.com/oembed")
75
+ provider << "http://bar.foo.com/*/show/*"
76
76
 
77
- expect(provier).to include("http://bar.foo.com/photo/show/1")
78
- expect(provier).to include("http://bar.foo.com/video/show/2")
79
- expect(provier).to include("http://bar.foo.com/help/video/show/2")
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(provier).to_not include("https://bar.foo.com/photo/show/1")
82
- expect(provier).to_not include("http://foo.com/video/show/2")
83
- expect(provier).to_not include("http://bar.foo.com/show/1")
84
- expect(provier).to_not include("http://bar.foo.com/1")
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
- provier = OEmbed::Provider.new("http://foo.com/oembed")
88
+ provider = OEmbed::Provider.new("http://foo.com/oembed")
89
89
 
90
- expect { provier << "http://*.com/*" }.
90
+ expect { provider << "http://*.com/*" }.
91
91
  to raise_error(ArgumentError)
92
92
 
93
- expect(provier).to_not include("http://foo.com/1")
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
- provier = OEmbed::Provider.new("http://foo.com/oembed")
98
- provier << "http://*.foo.com/*"
97
+ provider = OEmbed::Provider.new("http://foo.com/oembed")
98
+ provider << "http://*.foo.com/*"
99
99
 
100
- expect(provier).to include("http://bar.foo.com/1")
101
- expect(provier).to include("http://foo.foo.com/2")
102
- expect(provier).to include("http://foo.com/3")
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(provier).to_not include("https://bar.foo.com/1")
105
- expect(provier).to_not include("http://my.bar.foo.com/1")
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
- provier << "http://my.*.foo.com/*"
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
- provier = OEmbed::Provider.new("http://foo.com/oembed")
112
- provier << "http://*.my.*.foo.com/*"
111
+ provider = OEmbed::Provider.new("http://foo.com/oembed")
112
+ provider << "http://*.my.*.foo.com/*"
113
113
 
114
- expect(provier).to include("http://my.bar.foo.com/1")
115
- expect(provier).to include("http://my.foo.com/2")
116
- expect(provier).to include("http://bar.my.bar.foo.com/3")
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(provier).to_not include("http://bar.foo.com/1")
119
- expect(provier).to_not include("http://foo.bar.foo.com/1")
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
- provier = OEmbed::Provider.new("http://foo.com/oembed")
123
+ provider = OEmbed::Provider.new("http://foo.com/oembed")
124
124
 
125
- expect { provier << "*://foo.com/*" }.
125
+ expect { provider << "*://foo.com/*" }.
126
126
  to raise_error(ArgumentError)
127
127
 
128
- expect(provier).to_not include("http://foo.com/1")
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
- provier = OEmbed::Provider.new("http://foo.com/oembed")
133
- provier << "https://foo.com/*"
132
+ provider = OEmbed::Provider.new("http://foo.com/oembed")
133
+ provider << "https://foo.com/*"
134
134
 
135
- expect(provier).to include("https://foo.com/1")
135
+ expect(provider).to include("https://foo.com/1")
136
136
 
137
137
  gopher_url = "gopher://foo.com/1"
138
- expect(provier).to_not include(gopher_url)
139
- provier << "gopher://foo.com/*"
140
- expect(provier).to include(gopher_url)
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
- provier = OEmbed::Provider.new("http://foo.com/oembed")
145
- provier << %r{^https?://([^\.]*\.)?foo.com/(show/)?\d+}
144
+ provider = OEmbed::Provider.new("http://foo.com/oembed")
145
+ provider << %r{^https?://([^\.]*\.)?foo.com/(show/)?\d+}
146
146
 
147
- expect(provier).to include("http://bar.foo.com/1")
148
- expect(provier).to include("http://bar.foo.com/show/1")
149
- expect(provier).to include("http://foo.com/1")
150
- expect(provier).to include("https://bar.foo.com/1")
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(provier).to_not include("http://bar.foo.com/video/1")
153
- expect(provier).to_not include("gopher://foo.com/1")
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
- expect {
271
- res = @vimeo_ssl.send(:raw, example_url(:vimeo_ssl))
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
- # Note: This test relies on a custom-written VCR response in the
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
- # Note: This test relies on a custom-written VCR response in the
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
- it "should raise an UnknownResponse error on other responses" do
295
- # Note: This test relies on a custom-written VCR response in the
296
- # cassettes/OEmbed_Provider.yml file.
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)