ruby-oembed 0.13.1 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -2
- data/CHANGELOG.rdoc +25 -1
- data/README.md +23 -5
- data/lib/oembed/provider.rb +54 -5
- data/lib/oembed/providers/{embedly_urls.yml → aggregators/embedly_urls.yml} +0 -0
- data/lib/oembed/providers/{noembed_urls.yml → aggregators/noembed_urls.yml} +0 -0
- data/lib/oembed/providers/{oohembed_urls.yml → aggregators/oohembed_urls.yml} +0 -0
- data/lib/oembed/providers/builtin_providers.rb +297 -0
- data/lib/oembed/providers/facebook_post.rb +35 -0
- data/lib/oembed/providers/facebook_video.rb +30 -0
- data/lib/oembed/providers/instagram.rb +45 -0
- data/lib/oembed/providers/tiktok.rb +13 -0
- data/lib/oembed/providers.rb +46 -322
- data/lib/oembed/version.rb +2 -2
- data/lib/oembed.rb +1 -0
- data/lib/tasks/oembed.rake +2 -2
- data/ruby-oembed.gemspec +1 -2
- metadata +16 -55
- data/integration_test/test.rb +0 -31
- data/integration_test/test_urls.csv +0 -502
- data/spec/cassettes/OEmbed_Provider.yml +0 -987
- data/spec/cassettes/OEmbed_ProviderDiscovery.yml +0 -27184
- data/spec/cassettes/OEmbed_Providers_Slideshare.yml +0 -1433
- data/spec/cassettes/OEmbed_Providers_Twitter.yml +0 -612
- data/spec/formatter/ducktype_backend_spec.rb +0 -94
- data/spec/formatter/json/.DS_Store +0 -0
- data/spec/formatter/json/jsongem_backend_spec.rb +0 -71
- data/spec/formatter/json/yaml_backend_spec.rb +0 -55
- data/spec/formatter/xml/nokogiri_backend_spec.rb +0 -59
- data/spec/formatter/xml/rexml_backend_spec.rb +0 -55
- data/spec/formatter/xml/xmlsimple_backend_spec.rb +0 -59
- data/spec/formatter_spec.rb +0 -37
- data/spec/provider_discovery_spec.rb +0 -141
- data/spec/provider_spec.rb +0 -366
- data/spec/providers/slideshare_spec.rb +0 -42
- data/spec/providers/twitter_spec.rb +0 -44
- data/spec/providers_spec.rb +0 -258
- data/spec/response_spec.rb +0 -230
- data/spec/spec_helper.rb +0 -111
- data/spec/spec_helper_examples.yml +0 -27
- data/spec/support/shared_examples_for_providers.rb +0 -39
data/spec/provider_spec.rb
DELETED
@@ -1,366 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe OEmbed::Provider do
|
4
|
-
before(:all) do
|
5
|
-
VCR.insert_cassette('OEmbed_Provider')
|
6
|
-
end
|
7
|
-
after(:all) do
|
8
|
-
VCR.eject_cassette
|
9
|
-
end
|
10
|
-
|
11
|
-
include OEmbedSpecHelper
|
12
|
-
|
13
|
-
before(:all) do
|
14
|
-
@default = OEmbed::Formatter.default
|
15
|
-
@flickr = OEmbed::Provider.new("http://www.flickr.com/services/oembed/")
|
16
|
-
@qik = OEmbed::Provider.new("http://qik.com/api/oembed.{format}", :xml)
|
17
|
-
@viddler = OEmbed::Provider.new("http://lab.viddler.com/services/oembed/", :json)
|
18
|
-
|
19
|
-
@flickr << "http://*.flickr.com/*"
|
20
|
-
@qik << "http://qik.com/video/*"
|
21
|
-
@qik << "http://qik.com/*"
|
22
|
-
@viddler << "http://*.viddler.com/*"
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should require a valid endpoint for a new instance" do
|
26
|
-
expect { OEmbed::Provider.new("http://foo.com/oembed/") }.
|
27
|
-
not_to raise_error
|
28
|
-
|
29
|
-
expect { OEmbed::Provider.new("https://foo.com/oembed/") }.
|
30
|
-
not_to raise_error
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should allow a {format} string in the endpoint for a new instance" do
|
34
|
-
expect { OEmbed::Provider.new("http://foo.com/oembed.{format}/get") }.
|
35
|
-
not_to raise_error
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should raise an ArgumentError given an invalid endpoint for a new instance" do
|
39
|
-
[
|
40
|
-
"httpx://foo.com/oembed/",
|
41
|
-
"ftp://foo.com/oembed/",
|
42
|
-
"foo.com/oembed/",
|
43
|
-
"http://not a uri",
|
44
|
-
nil, 1,
|
45
|
-
].each do |endpoint|
|
46
|
-
expect { OEmbed::Provider.new(endpoint) }.
|
47
|
-
to raise_error(ArgumentError)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
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")
|
60
|
-
end
|
61
|
-
|
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/*"
|
65
|
-
|
66
|
-
expect(provier).to include("http://bar.foo.com/1")
|
67
|
-
expect(provier).to include("http://bar.foo.com/show/1")
|
68
|
-
|
69
|
-
expect(provier).to_not include("https://bar.foo.com/1")
|
70
|
-
expect(provier).to_not include("http://foo.com/1")
|
71
|
-
end
|
72
|
-
|
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/*"
|
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")
|
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")
|
85
|
-
end
|
86
|
-
|
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")
|
89
|
-
|
90
|
-
expect { provier << "http://*.com/*" }.
|
91
|
-
to raise_error(ArgumentError)
|
92
|
-
|
93
|
-
expect(provier).to_not include("http://foo.com/1")
|
94
|
-
end
|
95
|
-
|
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/*"
|
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")
|
103
|
-
|
104
|
-
expect(provier).to_not include("https://bar.foo.com/1")
|
105
|
-
expect(provier).to_not include("http://my.bar.foo.com/1")
|
106
|
-
|
107
|
-
provier << "http://my.*.foo.com/*"
|
108
|
-
end
|
109
|
-
|
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/*"
|
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")
|
117
|
-
|
118
|
-
expect(provier).to_not include("http://bar.foo.com/1")
|
119
|
-
expect(provier).to_not include("http://foo.bar.foo.com/1")
|
120
|
-
end
|
121
|
-
|
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")
|
124
|
-
|
125
|
-
expect { provier << "*://foo.com/*" }.
|
126
|
-
to raise_error(ArgumentError)
|
127
|
-
|
128
|
-
expect(provier).to_not include("http://foo.com/1")
|
129
|
-
end
|
130
|
-
|
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/*"
|
134
|
-
|
135
|
-
expect(provier).to include("https://foo.com/1")
|
136
|
-
|
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)
|
141
|
-
end
|
142
|
-
|
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+}
|
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")
|
151
|
-
|
152
|
-
expect(provier).to_not include("http://bar.foo.com/video/1")
|
153
|
-
expect(provier).to_not include("gopher://foo.com/1")
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should by default use OEmbed::Formatter.default" do
|
157
|
-
expect(@flickr.format).to eq(@default)
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should allow xml" do
|
161
|
-
expect(@qik.format).to eq(:xml)
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should allow json" do
|
165
|
-
expect(@viddler.format).to eq(:json)
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should allow random formats on initialization" do
|
169
|
-
expect {
|
170
|
-
yaml_provider = OEmbed::Provider.new("http://foo.com/api/oembed.{format}", :yml)
|
171
|
-
yaml_provider << "http://foo.com/*"
|
172
|
-
}.
|
173
|
-
not_to raise_error
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should not allow random formats to be parsed" do
|
177
|
-
yaml_provider = OEmbed::Provider.new("http://foo.com/api/oembed.{format}", :yml)
|
178
|
-
yaml_provider << "http://foo.com/*"
|
179
|
-
yaml_url = "http://foo.com/video/1"
|
180
|
-
|
181
|
-
expect(yaml_provider).to receive(:raw).
|
182
|
-
with(yaml_url, {:format=>:yml}).
|
183
|
-
and_return(valid_response(:json))
|
184
|
-
|
185
|
-
expect { yaml_provider.get(yaml_url) }.
|
186
|
-
to raise_error(OEmbed::FormatNotSupported)
|
187
|
-
end
|
188
|
-
|
189
|
-
it "should add URL schemes" do
|
190
|
-
expect(@flickr.urls).to eq([%r{^http://([^\.]+\.)?flickr\.com/(.*?)}])
|
191
|
-
expect(@qik.urls).to eq([%r{^http://qik\.com/video/(.*?)},
|
192
|
-
%r{^http://qik\.com/(.*?)}])
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should match URLs" do
|
196
|
-
expect(@flickr).to include(example_url(:flickr))
|
197
|
-
expect(@qik).to include(example_url(:qik))
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should raise error if the URL is invalid" do
|
201
|
-
expect{ @flickr.send(:build, example_url(:fake)) }.to raise_error(OEmbed::NotFound)
|
202
|
-
expect{ @qik.send(:build, example_url(:fake)) }.to raise_error(OEmbed::NotFound)
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "#build" do
|
206
|
-
it "should return a proper URL" do
|
207
|
-
uri = @flickr.send(:build, example_url(:flickr))
|
208
|
-
expect(uri.host).to eq("www.flickr.com")
|
209
|
-
expect(uri.path).to eq("/services/oembed/")
|
210
|
-
expect(uri.query).to include("format=#{@flickr.format}")
|
211
|
-
expect(uri.query).to include("url=#{CGI.escape 'http://flickr.com/photos/bees/2362225867/'}")
|
212
|
-
|
213
|
-
uri = @qik.send(:build, example_url(:qik))
|
214
|
-
expect(uri.host).to eq("qik.com")
|
215
|
-
expect(uri.path).to eq("/api/oembed.xml")
|
216
|
-
expect(uri.query).to_not include("format=#{@qik.format}")
|
217
|
-
expect(uri.query).to eq("url=#{CGI.escape 'http://qik.com/video/49565'}")
|
218
|
-
end
|
219
|
-
|
220
|
-
it "should accept parameters" do
|
221
|
-
uri = @flickr.send(:build, example_url(:flickr),
|
222
|
-
:maxwidth => 600,
|
223
|
-
:maxheight => 200,
|
224
|
-
:format => :xml,
|
225
|
-
:another => "test")
|
226
|
-
|
227
|
-
expect(uri.query).to include("maxwidth=600")
|
228
|
-
expect(uri.query).to include("maxheight=200")
|
229
|
-
expect(uri.query).to include("format=xml")
|
230
|
-
expect(uri.query).to include("another=test")
|
231
|
-
end
|
232
|
-
|
233
|
-
it "should build correctly when format is in the endpoint URL" do
|
234
|
-
uri = @qik.send(:build, example_url(:qik), :format => :json)
|
235
|
-
expect(uri.path).to eq("/api/oembed.json")
|
236
|
-
end
|
237
|
-
|
238
|
-
it "should build correctly with query parameters in the endpoint URL" do
|
239
|
-
provider = OEmbed::Provider.new('http://www.youtube.com/oembed?scheme=https')
|
240
|
-
provider << 'http://*.youtube.com/*'
|
241
|
-
url = 'http://youtube.com/watch?v=M3r2XDceM6A'
|
242
|
-
expect(provider).to include(url)
|
243
|
-
|
244
|
-
uri = provider.send(:build, url)
|
245
|
-
expect(uri.query).to include("scheme=https")
|
246
|
-
expect(uri.query).to include("url=#{CGI.escape url}")
|
247
|
-
end
|
248
|
-
|
249
|
-
it "should not include the :timeout parameter in the query string" do
|
250
|
-
uri = @flickr.send(:build, example_url(:flickr),
|
251
|
-
:timeout => 5,
|
252
|
-
:another => "test")
|
253
|
-
|
254
|
-
expect(uri.query).to_not include("timeout=5")
|
255
|
-
expect(uri.query).to include("another=test")
|
256
|
-
end
|
257
|
-
end
|
258
|
-
|
259
|
-
describe "#raw" do
|
260
|
-
it "should return the body on 200" do
|
261
|
-
res = @flickr.send(:raw, example_url(:flickr))
|
262
|
-
expect(res).to eq(example_body(:flickr))
|
263
|
-
end
|
264
|
-
|
265
|
-
it "should return the body on 200 even over https" do
|
266
|
-
@vimeo_ssl = OEmbed::Provider.new("https://vimeo.com/api/oembed.{format}")
|
267
|
-
@vimeo_ssl << "http://*.vimeo.com/*"
|
268
|
-
@vimeo_ssl << "https://*.vimeo.com/*"
|
269
|
-
|
270
|
-
res = @vimeo_ssl.send(:raw, example_url(:vimeo_ssl))
|
271
|
-
expect(res).to eq(example_body(:vimeo_ssl).strip)
|
272
|
-
end
|
273
|
-
|
274
|
-
it "should raise an UnknownFormat error on 501" do
|
275
|
-
stub_request(:get, /flickr/).to_return(status: 501)
|
276
|
-
|
277
|
-
expect {
|
278
|
-
result = @flickr.send(:raw, File.join(example_url(:flickr), '501'))
|
279
|
-
}.to raise_error(OEmbed::UnknownFormat)
|
280
|
-
end
|
281
|
-
|
282
|
-
it "should raise a NotFound error on 404" do
|
283
|
-
stub_request(:get, /flickr/).to_return(status: 404)
|
284
|
-
|
285
|
-
expect {
|
286
|
-
@flickr.send(:raw, File.join(example_url(:flickr), '404'))
|
287
|
-
}.to raise_error(OEmbed::NotFound)
|
288
|
-
end
|
289
|
-
|
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)
|
293
|
-
|
294
|
-
expect {
|
295
|
-
@flickr.send(:raw, File.join(example_url(:flickr), status))
|
296
|
-
}.to raise_error(OEmbed::UnknownResponse)
|
297
|
-
end
|
298
|
-
end
|
299
|
-
end
|
300
|
-
|
301
|
-
describe "#get" do
|
302
|
-
it "should send the specified format" do
|
303
|
-
expect(@flickr).to receive(:raw).
|
304
|
-
with(example_url(:flickr), {:format=>:json}).
|
305
|
-
and_return(valid_response(:json))
|
306
|
-
@flickr.get(example_url(:flickr), :format=>:json)
|
307
|
-
|
308
|
-
expect(@flickr).to receive(:raw).
|
309
|
-
with(example_url(:flickr), {:format=>:xml}).
|
310
|
-
and_return(valid_response(:xml))
|
311
|
-
@flickr.get(example_url(:flickr), :format=>:xml)
|
312
|
-
|
313
|
-
expect {
|
314
|
-
expect(@flickr).to receive(:raw).
|
315
|
-
with(example_url(:flickr), {:format=>:yml}).
|
316
|
-
and_return(valid_response(:json))
|
317
|
-
@flickr.get(example_url(:flickr), :format=>:yml)
|
318
|
-
}.to raise_error(OEmbed::FormatNotSupported)
|
319
|
-
end
|
320
|
-
|
321
|
-
it "should return OEmbed::Response" do
|
322
|
-
allow(@flickr).to receive(:raw).and_return(valid_response(@default))
|
323
|
-
expect(@flickr.get(example_url(:flickr))).to be_a(OEmbed::Response)
|
324
|
-
end
|
325
|
-
|
326
|
-
it "should be calling OEmbed::Response#create_for internally" do
|
327
|
-
allow(@flickr).to receive(:raw).and_return(valid_response(@default))
|
328
|
-
expect(OEmbed::Response).to receive(:create_for).
|
329
|
-
with(valid_response(@default), @flickr, example_url(:flickr), @default.to_s)
|
330
|
-
@flickr.get(example_url(:flickr))
|
331
|
-
|
332
|
-
allow(@qik).to receive(:raw).and_return(valid_response(:xml))
|
333
|
-
expect(OEmbed::Response).to receive(:create_for).
|
334
|
-
with(valid_response(:xml), @qik, example_url(:qik), 'xml')
|
335
|
-
@qik.get(example_url(:qik))
|
336
|
-
|
337
|
-
allow(@viddler).to receive(:raw).and_return(valid_response(:json))
|
338
|
-
expect(OEmbed::Response).to receive(:create_for).
|
339
|
-
with(valid_response(:json), @viddler, example_url(:viddler), 'json')
|
340
|
-
@viddler.get(example_url(:viddler))
|
341
|
-
end
|
342
|
-
|
343
|
-
it "should send the provider's format if none is specified" do
|
344
|
-
expect(@flickr).to receive(:raw).
|
345
|
-
with(example_url(:flickr), :format => @default).
|
346
|
-
and_return(valid_response(@default))
|
347
|
-
@flickr.get(example_url(:flickr))
|
348
|
-
|
349
|
-
expect(@qik).to receive(:raw).
|
350
|
-
with(example_url(:qik), :format=>:xml).
|
351
|
-
and_return(valid_response(:xml))
|
352
|
-
@qik.get(example_url(:qik))
|
353
|
-
|
354
|
-
expect(@viddler).to receive(:raw).
|
355
|
-
with(example_url(:viddler), :format=>:json).
|
356
|
-
and_return(valid_response(:json))
|
357
|
-
@viddler.get(example_url(:viddler))
|
358
|
-
end
|
359
|
-
|
360
|
-
it "handles the :timeout option", pending: true do
|
361
|
-
expect_any_instance_of(Net::HTTP).to receive(:open_timeout=).with(5)
|
362
|
-
expect_any_instance_of(Net::HTTP).to receive(:read_timeout=).with(5)
|
363
|
-
@flickr.get(example_url(:flickr), :timeout => 5)
|
364
|
-
end
|
365
|
-
end
|
366
|
-
end
|
@@ -1,42 +0,0 @@
|
|
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
|
@@ -1,44 +0,0 @@
|
|
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, /\b400\b/)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|