ruby-oembed 0.14.0 → 0.16.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -2
  3. data/CHANGELOG.rdoc +25 -2
  4. data/README.md +5 -7
  5. data/lib/oembed/provider.rb +54 -5
  6. data/lib/oembed/providers/builtin_providers.rb +292 -0
  7. data/lib/oembed/providers/facebook_post.rb +27 -17
  8. data/lib/oembed/providers/facebook_video.rb +22 -10
  9. data/lib/oembed/providers/instagram.rb +37 -20
  10. data/lib/oembed/providers/tiktok.rb +13 -0
  11. data/lib/oembed/providers.rb +39 -300
  12. data/lib/oembed/version.rb +2 -2
  13. data/lib/oembed.rb +1 -0
  14. data/ruby-oembed.gemspec +1 -2
  15. metadata +9 -53
  16. data/integration_test/test.rb +0 -31
  17. data/integration_test/test_urls.csv +0 -502
  18. data/spec/cassettes/OEmbed_Provider.yml +0 -987
  19. data/spec/cassettes/OEmbed_ProviderDiscovery.yml +0 -27184
  20. data/spec/cassettes/OEmbed_Providers_Slideshare.yml +0 -1433
  21. data/spec/cassettes/OEmbed_Providers_Twitter.yml +0 -612
  22. data/spec/formatter/ducktype_backend_spec.rb +0 -94
  23. data/spec/formatter/json/.DS_Store +0 -0
  24. data/spec/formatter/json/jsongem_backend_spec.rb +0 -71
  25. data/spec/formatter/json/yaml_backend_spec.rb +0 -55
  26. data/spec/formatter/xml/nokogiri_backend_spec.rb +0 -59
  27. data/spec/formatter/xml/rexml_backend_spec.rb +0 -55
  28. data/spec/formatter/xml/xmlsimple_backend_spec.rb +0 -59
  29. data/spec/formatter_spec.rb +0 -37
  30. data/spec/provider_discovery_spec.rb +0 -141
  31. data/spec/provider_spec.rb +0 -366
  32. data/spec/providers/facebook_spec.rb +0 -50
  33. data/spec/providers/slideshare_spec.rb +0 -42
  34. data/spec/providers/twitter_spec.rb +0 -44
  35. data/spec/providers_spec.rb +0 -306
  36. data/spec/response_spec.rb +0 -230
  37. data/spec/spec_helper.rb +0 -111
  38. data/spec/spec_helper_examples.yml +0 -27
  39. data/spec/support/shared_examples_for_providers.rb +0 -39
@@ -1,306 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe OEmbed::Providers do
4
- include OEmbedSpecHelper
5
-
6
- before(:all) do
7
- @flickr = OEmbed::Provider.new("http://www.flickr.com/services/oembed/")
8
- @qik = OEmbed::Provider.new("http://qik.com/api/oembed.{format}")
9
-
10
- @flickr << "http://*.flickr.com/*"
11
- @qik << "http://qik.com/video/*"
12
- @qik << "http://qik.com/*"
13
- end
14
-
15
- after(:each) do
16
- OEmbed::Providers.unregister_all
17
- end
18
-
19
- describe ".register" do
20
- it "should register providers" do
21
- expect(OEmbed::Providers.urls).to be_empty
22
-
23
- OEmbed::Providers.register(@flickr, @qik)
24
-
25
- expect(OEmbed::Providers.urls.keys).to eq(@flickr.urls + @qik.urls)
26
-
27
- @flickr.urls.each do |regexp|
28
- expect(OEmbed::Providers.urls).to have_key(regexp)
29
- expect(OEmbed::Providers.urls[regexp]).to include(@flickr)
30
- end
31
-
32
- @qik.urls.each do |regexp|
33
- expect(OEmbed::Providers.urls).to have_key(regexp)
34
- expect(OEmbed::Providers.urls[regexp]).to include(@qik)
35
- end
36
- end
37
-
38
- it "should find by URLs" do
39
- OEmbed::Providers.register(@flickr, @qik) # tested in "should register providers"
40
-
41
- expect(OEmbed::Providers.find(example_url(:flickr))).to eq(@flickr)
42
- expect(OEmbed::Providers.find(example_url(:qik))).to eq(@qik)
43
- end
44
- end
45
-
46
- describe ".unregister" do
47
- it "should unregister providers" do
48
- OEmbed::Providers.register(@flickr, @qik) # tested in "should register providers"
49
-
50
- OEmbed::Providers.unregister(@flickr)
51
-
52
- @flickr.urls.each do |regexp|
53
- expect(OEmbed::Providers.urls).to_not have_key(regexp)
54
- end
55
-
56
- expect(OEmbed::Providers.urls.keys).to eq(@qik.urls)
57
-
58
- @qik.urls.each do |regexp|
59
- expect(OEmbed::Providers.urls).to have_key(regexp)
60
- expect(OEmbed::Providers.urls[regexp]).to include(@qik)
61
- end
62
- end
63
-
64
- it "should not unregister duplicate provider urls at first" do
65
- @qik_mirror = OEmbed::Provider.new("http://mirror.qik.com/api/oembed.{format}")
66
- @qik_mirror << "http://qik.com/*"
67
-
68
- @qik_mirror.urls.each do |regexp|
69
- expect(@qik.urls).to include(regexp)
70
- end
71
-
72
- OEmbed::Providers.register(@qik, @qik_mirror)
73
-
74
- expect(OEmbed::Providers.urls.keys).to eq(@qik.urls)
75
-
76
- @qik_mirror.urls.each do |regexp|
77
- expect(OEmbed::Providers.urls[regexp]).to include(@qik_mirror)
78
- expect(OEmbed::Providers.urls[regexp]).to include(@qik)
79
- end
80
-
81
- expect(OEmbed::Providers.find(example_url(:qik))).to eq(@qik)
82
-
83
- OEmbed::Providers.unregister(@qik)
84
-
85
- urls = OEmbed::Providers.urls.dup
86
-
87
- @qik_mirror.urls.each do |regexp|
88
- expect(OEmbed::Providers.urls[regexp]).to include(@qik_mirror)
89
- end
90
-
91
- expect(OEmbed::Providers.find(example_url(:qik))).to eq(@qik_mirror)
92
-
93
- OEmbed::Providers.unregister(@qik_mirror)
94
-
95
- @qik_mirror.urls.each do |regexp|
96
- expect(OEmbed::Providers.urls).to_not have_key(regexp)
97
- end
98
- end
99
- end
100
-
101
- #it "should use the OEmbed::ProviderDiscovery fallback provider correctly" do
102
- # url = example_url(:vimeo)
103
- #
104
- # # None of the registered providers should match
105
- # all_example_urls.each do |url|
106
- # provider = OEmbed::Providers.find(url)
107
- # if provider
108
- # provider.should_not_receive(:raw)
109
- # provider.should_not_receive(:get)
110
- # end
111
- # end
112
- #
113
- # # Register the fallback
114
- # OEmbed::Providers.register_fallback(OEmbed::ProviderDiscovery)
115
- #
116
- # provider = OEmbed::ProviderDiscovery
117
- # expect(provider).to receive(:raw).
118
- # with(url, {}).
119
- # and_return(valid_response(:raw))
120
- # expect(provider).to receive(:get).
121
- # with(url, {}).
122
- # and_return(valid_response(:object))
123
- #end
124
-
125
- describe "#raw and #get" do
126
- it "should bridge #get and #raw to the right provider" do
127
- OEmbed::Providers.register_all
128
- all_example_urls.each do |url|
129
- provider = OEmbed::Providers.find(url)
130
- expect(provider).to receive(:raw).
131
- with(url, {})
132
- expect(provider).to receive(:get).
133
- with(url, {})
134
- OEmbed::Providers.raw(url)
135
- OEmbed::Providers.get(url)
136
- end
137
- end
138
-
139
- it "should raise an error if no embeddable content is found" do
140
- OEmbed::Providers.register_all
141
- ["http://fake.com/", example_url(:google_video)].each do |url|
142
- expect { OEmbed::Providers.get(url) }.to raise_error(OEmbed::NotFound)
143
- expect { OEmbed::Providers.raw(url) }.to raise_error(OEmbed::NotFound)
144
- end
145
- end
146
- end
147
-
148
- describe ".register_fallback" do
149
- it "should register fallback providers" do
150
- OEmbed::Providers.register_fallback(OEmbed::Providers::Hulu)
151
- OEmbed::Providers.register_fallback(OEmbed::Providers::OohEmbed)
152
-
153
- expect(OEmbed::Providers.fallback).to eq([ OEmbed::Providers::Hulu, OEmbed::Providers::OohEmbed])
154
- end
155
-
156
- it "should fallback to the appropriate provider when URL isn't found" do
157
- OEmbed::Providers.register_all
158
- OEmbed::Providers.register_fallback(OEmbed::Providers::Hulu)
159
- OEmbed::Providers.register_fallback(OEmbed::Providers::OohEmbed)
160
-
161
- url = example_url(:google_video)
162
-
163
- provider = OEmbed::Providers.fallback.last
164
- expect(provider).to receive(:raw).
165
- with(url, {}).
166
- and_return(valid_response(:raw))
167
- expect(provider).to receive(:get).
168
- with(url, {}).
169
- and_return(valid_response(:object))
170
-
171
- OEmbed::Providers.fallback.each do |p|
172
- next if p == provider
173
- expect(p).to receive(:raw).and_raise(OEmbed::NotFound)
174
- expect(p).to receive(:get).and_raise(OEmbed::NotFound)
175
- end
176
-
177
- OEmbed::Providers.raw(url)
178
- OEmbed::Providers.get(url)
179
- end
180
-
181
- it "should still raise an error if no embeddable content is found" do
182
- OEmbed::Providers.register_all
183
- OEmbed::Providers.register_fallback(OEmbed::Providers::Hulu)
184
- OEmbed::Providers.register_fallback(OEmbed::Providers::OohEmbed)
185
-
186
- ["http://fa.ke/"].each do |url|
187
- expect { OEmbed::Providers.get(url) }.to raise_error(OEmbed::NotFound)
188
- expect { OEmbed::Providers.raw(url) }.to raise_error(OEmbed::NotFound)
189
- end
190
- end
191
- end
192
-
193
- describe ".register_all" do
194
- after(:each) do
195
- OEmbed::Providers.send(:remove_const, :Fake) if defined?(OEmbed::Providers::Fake)
196
- end
197
-
198
- it "should not register a provider that is not marked as official" do
199
- expect(defined?(OEmbed::Providers::Fake)).to_not be
200
-
201
- class OEmbed::Providers
202
- Fake = OEmbed::Provider.new("http://new.fa.ke/oembed/")
203
- Fake << "http://new.fa.ke/*"
204
- end
205
-
206
- OEmbed::Providers.register_all
207
- ["http://new.fa.ke/20C285E0"].each do |url|
208
- provider = OEmbed::Providers.find(url)
209
- expect(provider).to be_nil
210
- end
211
- end
212
-
213
- describe 'register_access_token_providers' do
214
- describe 'tokens[:facebook]' do
215
- let(:access_token) { 'my-fake-access-token' }
216
- let(:embed_url) { 'https://www.facebook.com/exampleuser/posts/1234567890' }
217
-
218
- around(:each) do |each|
219
- previous_value = ENV['OEMBED_FACEBOOK_TOKEN']
220
- ENV['OEMBED_FACEBOOK_TOKEN'] = nil
221
- each.run
222
- ENV['OEMBED_FACEBOOK_TOKEN'] = previous_value
223
- OEmbed::Providers.unregister_all
224
- end
225
-
226
- subject { OEmbed::Providers.find(embed_url) }
227
-
228
- context 'when NO access token is provided' do
229
- before do
230
- OEmbed::Providers.register_all
231
- end
232
-
233
- it { is_expected.to_not be_a(OEmbed::Providers::FacebookPost) }
234
- end
235
-
236
- context 'when access token is provided to register_all' do
237
- before do
238
- OEmbed::Providers.register_all(access_tokens: { facebook: access_token })
239
- end
240
-
241
- it { is_expected.to be_a(OEmbed::Providers::FacebookPost) }
242
- end
243
-
244
- context 'when access token is set as an environment variable' do
245
- before do
246
- ENV['OEMBED_FACEBOOK_TOKEN'] = access_token
247
- OEmbed::Providers.register_all
248
- end
249
-
250
- it { is_expected.to be_a(OEmbed::Providers::FacebookPost) }
251
- end
252
-
253
- context 'without access token' do
254
- before { OEmbed::Providers.register_all }
255
-
256
- it { is_expected.to eq(nil) }
257
- end
258
- end
259
- end
260
-
261
- describe 'add_official_provider' do
262
- it "should register a new official provider" do
263
- expect(defined?(OEmbed::Providers::Fake)).to_not be
264
-
265
- class OEmbed::Providers
266
- Fake = OEmbed::Provider.new("http://official.fa.ke/oembed/")
267
- Fake << "http://official.fa.ke/*"
268
- add_official_provider(Fake)
269
- end
270
-
271
- ["http://official.fa.ke/20C285E0"].each do |url|
272
- provider = OEmbed::Providers.find(url)
273
- expect(provider).to_not be_a(OEmbed::Provider)
274
- end
275
-
276
- OEmbed::Providers.register_all
277
- ["http://official.fa.ke/20C285E0"].each do |url|
278
- provider = OEmbed::Providers.find(url)
279
- expect(provider).to be_a(OEmbed::Provider)
280
- end
281
- end
282
-
283
- it "should register an official sub_type provider separately" do
284
- expect(defined?(OEmbed::Providers::Fake)).to_not be
285
-
286
- class OEmbed::Providers
287
- Fake = OEmbed::Provider.new("http://sub.fa.ke/oembed/")
288
- Fake << "http://sub.fa.ke/*"
289
- add_official_provider(Fake, :fakes)
290
- end
291
-
292
- OEmbed::Providers.register_all
293
- ["http://sub.fa.ke/20C285E0"].each do |url|
294
- provider = OEmbed::Providers.find(url)
295
- expect(provider).to_not be_a(OEmbed::Provider)
296
- end
297
-
298
- OEmbed::Providers.register_all(:fakes)
299
- ["http://sub.fa.ke/20C285E0"].each do |url|
300
- provider = OEmbed::Providers.find(url)
301
- expect(provider).to be_a(OEmbed::Provider)
302
- end
303
- end
304
- end
305
- end
306
- end
@@ -1,230 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- def expected_helpers
4
- {
5
- "type" => "random",
6
- "version" => "1.0",
7
- "html" => "&lt;em&gt;Hello world!&lt;/em&gt;",
8
- "url" => "http://foo.com/bar",
9
- }.freeze
10
- end
11
-
12
- def expected_skipped
13
- {
14
- "fields" => "hello",
15
- "__id__" => 1234,
16
- "provider" => "oohEmbed",
17
- "to_s" => "random string",
18
- }.freeze
19
- end
20
-
21
- def all_expected
22
- expected_helpers.merge(expected_skipped).freeze
23
- end
24
-
25
- describe OEmbed::Response do
26
- include OEmbedSpecHelper
27
-
28
- let(:flickr) {
29
- flickr = OEmbed::Provider.new("http://www.flickr.com/services/oembed/")
30
- flickr << "http://*.flickr.com/*"
31
- flickr
32
- }
33
-
34
- let(:skitch) {
35
- OEmbed::Provider.new("https://skitch.com/oembed")
36
- }
37
-
38
- let(:qik) {
39
- qik = OEmbed::Provider.new("http://qik.com/api/oembed.{format}", :xml)
40
- qik << "http://qik.com/video/*"
41
- qik << "http://qik.com/*"
42
- qik
43
- }
44
-
45
- let(:viddler) {
46
- viddler = OEmbed::Provider.new("http://lab.viddler.com/services/oembed/", :json)
47
- viddler << "http://*.viddler.com/*"
48
- viddler
49
- }
50
-
51
- let(:new_res) {
52
- OEmbed::Response.new(valid_response(:object), OEmbed::Providers::OohEmbed)
53
- }
54
-
55
- let(:default_res) {
56
- OEmbed::Response.create_for(valid_response(:json), @flickr, example_url(:flickr), :json)
57
- }
58
-
59
- let(:xml_res) {
60
- OEmbed::Response.create_for(valid_response(:xml), @qik, example_url(:qik), :xml)
61
- }
62
-
63
- let(:json_res) {
64
- OEmbed::Response.create_for(valid_response(:json), @viddler, example_url(:viddler), :json)
65
- }
66
-
67
- describe "#initialize" do
68
- it "should parse the data into fields" do
69
- # We need to compare keys & values separately because we don't expect all
70
- # non-string values to be recognized correctly.
71
-
72
- expect(new_res.fields.keys).to eq(valid_response(:object).keys)
73
- expect(new_res.fields.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
74
-
75
- expect(default_res.fields.keys).to eq(valid_response(:object).keys)
76
- expect(default_res.fields.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
77
-
78
- expect(xml_res.fields.keys).to eq(valid_response(:object).keys)
79
- expect(xml_res.fields.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
80
-
81
- expect(json_res.fields.keys).to eq(valid_response(:object).keys)
82
- expect(json_res.fields.values.map{|v|v.to_s}).to eq(valid_response(:object).values.map{|v|v.to_s})
83
- end
84
-
85
- it "should set the provider" do
86
- expect(new_res.provider).to eq(OEmbed::Providers::OohEmbed)
87
- expect(default_res.provider).to eq(@flickr)
88
- expect(xml_res.provider).to eq(@qik)
89
- expect(json_res.provider).to eq(@viddler)
90
- end
91
-
92
- it "should set the format" do
93
- expect(new_res.format).to be_nil
94
- expect(default_res.format.to_s).to eq('json')
95
- expect(xml_res.format.to_s).to eq('xml')
96
- expect(json_res.format.to_s).to eq('json')
97
- end
98
-
99
- it "should set the request_url" do
100
- expect(new_res.request_url).to be_nil
101
- expect(default_res.request_url.to_s).to eq(example_url(:flickr))
102
- expect(xml_res.request_url.to_s).to eq(example_url(:qik))
103
- expect(json_res.request_url.to_s).to eq(example_url(:viddler))
104
- end
105
- end
106
-
107
- describe "create_for" do
108
- it "should only allow JSON or XML" do
109
- expect {
110
- OEmbed::Response.create_for(valid_response(:json), flickr, example_url(:flickr), :json)
111
- }.not_to raise_error
112
-
113
- expect {
114
- OEmbed::Response.create_for(valid_response(:xml), flickr, example_url(:flickr), :xml)
115
- }.not_to raise_error
116
-
117
- expect {
118
- OEmbed::Response.create_for(valid_response(:yml), flickr, example_url(:flickr), :yml)
119
- }.to raise_error(OEmbed::FormatNotSupported)
120
- end
121
-
122
- it "should not parse the incorrect format" do
123
- expect {
124
- OEmbed::Response.create_for(valid_response(:object), example_url(:flickr), flickr, :json)
125
- }.to raise_error(OEmbed::ParseError)
126
-
127
- expect {
128
- OEmbed::Response.create_for(valid_response(:xml), example_url(:flickr), viddler, :json)
129
- }.to raise_error(OEmbed::ParseError)
130
-
131
- expect {
132
- OEmbed::Response.create_for(valid_response(:json), example_url(:flickr), viddler, :xml)
133
- }.to raise_error(OEmbed::ParseError)
134
- end
135
- end
136
-
137
- it "should access the XML data through #field" do
138
- expect(xml_res.field(:type)).to eq("photo")
139
- expect(xml_res.field(:version)).to eq("1.0")
140
- expect(xml_res.field(:fields)).to eq("hello")
141
- expect(xml_res.field(:__id__)).to eq("1234")
142
- end
143
-
144
- it "should access the JSON data through #field" do
145
- expect(json_res.field(:type)).to eq("photo")
146
- expect(json_res.field(:version)).to eq("1.0")
147
- expect(json_res.field(:fields)).to eq("hello")
148
- expect(json_res.field(:__id__)).to eq("1234")
149
- end
150
-
151
- describe "#define_methods!" do
152
- context "with automagic" do
153
- all_expected.each do |method, value|
154
- before do
155
- @local_res = OEmbed::Response.new(all_expected, OEmbed::Providers::OohEmbed)
156
- end
157
-
158
- it "should define the #{method} method" do
159
- expect(@local_res).to respond_to(method)
160
- end
161
- end
162
-
163
- expected_helpers.each do |method, value|
164
- it "should define #{method} to return #{value.inspect}" do
165
- expect(@local_res.send(method)).to eq(value)
166
- end
167
- end
168
-
169
- expected_skipped.each do |method, value|
170
- it "should NOT override #{method} to not return #{value.inspect}" do
171
- expect(@local_res.send(method)).to_not eq(value)
172
- end
173
- end
174
- end
175
-
176
- it "should protect most already defined methods" do
177
- expect(Object.new).to respond_to('__id__')
178
- expect(Object.new).to respond_to('to_s')
179
-
180
- expect(all_expected.keys).to include('__id__')
181
- expect(all_expected.keys).to include('to_s')
182
-
183
- local_res = OEmbed::Response.new(all_expected, OEmbed::Providers::OohEmbed)
184
-
185
- expect(local_res.__id__).to_not eq(local_res.field('__id__'))
186
- expect(local_res.to_s).to_not eq(local_res.field('to_s'))
187
- end
188
-
189
- it "should not protect already defined methods that are specifically overridable" do
190
- class Object
191
- def version
192
- "two point oh"
193
- end
194
- end
195
-
196
- expect(Object.new).to respond_to('version')
197
- expect(String.new).to respond_to('version')
198
-
199
- expect(all_expected.keys).to include('version')
200
- expect(all_expected['version']).to_not eq(String.new.version)
201
-
202
- local_res = OEmbed::Response.new(all_expected, OEmbed::Providers::OohEmbed)
203
-
204
- expect(local_res.version).to eq(local_res.field('version'))
205
- expect(local_res.version).to_not eq(String.new.version)
206
- end
207
- end
208
-
209
- describe "OEmbed::Response::Photo" do
210
- describe "#html" do
211
- it "should include the title, if given" do
212
- response = OEmbed::Response.create_for(example_body(:flickr), example_url(:flickr), flickr, :json)
213
- expect(response).to respond_to(:title)
214
- expect(response.title).to_not be_empty
215
-
216
- expect(response.html).to_not be_nil
217
- expect(response.html).to match(/alt='#{response.title}'/)
218
- end
219
-
220
- it "should work just fine, without a title" do
221
- response = OEmbed::Response.create_for(example_body(:skitch), example_url(:skitch), skitch, :json)
222
- expect(response).to_not respond_to(:title)
223
-
224
- expect(response.html).to_not be_nil
225
- expect(response.html).to match(/alt=''/)
226
- end
227
- end
228
- end
229
-
230
- end
data/spec/spec_helper.rb DELETED
@@ -1,111 +0,0 @@
1
- require 'rubygems'
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.hook_into :webmock
8
- end
9
-
10
- require 'webmock/rspec'
11
- require 'coveralls'
12
- Coveralls.wear!
13
-
14
- require File.dirname(__FILE__) + '/../lib/oembed'
15
-
16
- RSpec.configure do |config|
17
- config.raise_errors_for_deprecations!
18
- config.tty = true
19
- config.color = true
20
- config.example_status_persistence_file_path = '.rspec-status'
21
- end
22
-
23
- module OEmbedSpecHelper
24
- EXAMPLE = YAML.load_file(File.expand_path(File.join(__FILE__, '../spec_helper_examples.yml'))) unless defined?(EXAMPLE)
25
-
26
- def example_url(site)
27
- return "http://fake.com/" if site == :fake
28
- EXAMPLE[site][:url]
29
- end
30
-
31
- def all_example_urls(*fallback)
32
- results = EXAMPLE.values.map{ |v| v[:url] }
33
-
34
- # By default don't return example_urls that won't be recognized by
35
- # the included default providers
36
- results.delete(example_url(:google_video))
37
-
38
- # If requested, return URLs that should work with various fallback providers
39
- fallback.each do |f|
40
- case f
41
- when OEmbed::Providers::OohEmbed
42
- results << example_url(:google_video)
43
- end
44
- end
45
-
46
- results
47
- end
48
-
49
- def example_body(site)
50
- EXAMPLE[site][:body]
51
- end
52
-
53
- def valid_response(format)
54
- case format.to_s
55
- when 'object'
56
- {
57
- "type" => "photo",
58
- "version" => "1.0",
59
- "fields" => "hello",
60
- "__id__" => 1234
61
- }
62
- when 'json'
63
- <<-JSON.strip
64
- {
65
- "type": "photo",
66
- "version": "1.0",
67
- "fields": "hello",
68
- "__id__": 1234
69
- }
70
- JSON
71
- when 'xml'
72
- <<-XML.strip
73
- <?xml version="1.0" encoding="utf-8" standalone="yes"?>
74
- <oembed>
75
- <type>photo</type>
76
- <version>1.0</version>
77
- <fields>hello</fields>
78
- <__id__>1234</__id__>
79
- </oembed>
80
- XML
81
- end
82
- end
83
-
84
- def invalid_response(case_name, format)
85
- format = format.to_s
86
- valid = valid_response(format)
87
- case case_name.to_s
88
- when 'unclosed_container'
89
- case format
90
- when 'json'
91
- valid_response(format).gsub(/\}\s*\z/, '')
92
- when 'xml'
93
- valid_response(format).gsub(%r{</oembed[^>]*>}, '')
94
- end
95
- when 'unclosed_tag'
96
- case format
97
- when 'json'
98
- valid_response(format).gsub('"photo"', '"photo')
99
- when 'xml'
100
- valid_response(format).gsub('</type>', '')
101
- end
102
- when 'invalid_syntax'
103
- case format
104
- when 'json'
105
- valid_response(format).gsub('"type"', '"type":')
106
- when 'xml'
107
- valid_response(format).gsub('type', 'ty><pe')
108
- end
109
- end
110
- end
111
- end
@@ -1,27 +0,0 @@
1
- ---
2
- :flickr:
3
- :url: "http://flickr.com/photos/bees/2362225867/"
4
- :body: |
5
- {"type":"photo","flickr_type":"photo","title":"Bacon Lollys","author_name":"\u202e\u202d\u202cbees\u202c","author_url":"https:\/\/www.flickr.com\/photos\/bees\/","width":1024,"height":768,"url":"https:\/\/live.staticflickr.com\/3040\/2362225867_4a87ab8baf_b.jpg","web_page":"https:\/\/www.flickr.com\/photos\/bees\/2362225867\/","thumbnail_url":"https:\/\/live.staticflickr.com\/3040\/2362225867_4a87ab8baf_q.jpg","thumbnail_width":150,"thumbnail_height":150,"web_page_short_url":"https:\/\/flic.kr\/p\/4AK2sc","license":"All Rights Reserved","license_id":0,"html":"<a data-flickr-embed=\"true\" href=\"https:\/\/www.flickr.com\/photos\/bees\/2362225867\/\" title=\"Bacon Lollys by \u202e\u202d\u202cbees\u202c, on Flickr\"><img src=\"https:\/\/live.staticflickr.com\/3040\/2362225867_4a87ab8baf_b.jpg\" width=\"1024\" height=\"768\" alt=\"Bacon Lollys\"><\/a><script async src=\"https:\/\/embedr.flickr.com\/assets\/client-code.js\" charset=\"utf-8\"><\/script>","version":"1.0","cache_age":3600,"provider_name":"Flickr","provider_url":"https:\/\/www.flickr.com\/"}
6
-
7
- :skitch:
8
- :url: "http://skitch.com/sethferreira/nmbr8/the-kings-new-toy"
9
- :body: ! '{"type":"photo","version":"1.0","author_name":"sethferreira","author_url":"http:\/\/skitch.com\/sethferreira\/","provider_name":"Skitch.com","provider_url":"http:\/\/skitch.com\/","width":804,"height":804,"url":"https:\/\/img.skitch.com\/20091210-m9cq9r2e6cy1j1sn23acn38kx.jpg","thumbnail_width":337,"thumbnail_height":337,"thumbnail_url":"https:\/\/img.skitch.com\/20091210-m9cq9r2e6cy1j1sn23acn38kx.preview.jpg","cache_age":86400}'
10
- :viddler:
11
- :url: "http://www.viddler.com/explore/cdevroe/videos/424/"
12
- :qik:
13
- :url: "http://qik.com/video/49565"
14
- :vimeo:
15
- :url: "http://vimeo.com/3100878"
16
- :body: |
17
- {"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"https:\/\/vimeo.com\/","title":"Murmuration","author_name":"Islands & Rivers","author_url":"https:\/\/vimeo.com\/islandsandrivers","is_plus":"0","account_type":"basic","html":"<iframe src=\"https:\/\/player.vimeo.com\/video\/31158841?app_id=122963\" width=\"400\" height=\"320\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen title=\"Murmuration\"><\/iframe>","width":400,"height":320,"duration":123,"description":"A chance encounter and shared moment with one of natures greatest and most fleeting phenomena.\n\nFacebook: Islands And Rivers\nFor licensing information contact Dale Dobson - dale@iconiclinx.com","thumbnail_url":"https:\/\/i.vimeocdn.com\/video\/448600816_295x166.jpg","thumbnail_width":295,"thumbnail_height":221,"thumbnail_url_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F448600816_295x166.jpg&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png","upload_date":"2011-10-26 14:43:13","video_id":31158841,"uri":"\/videos\/31158841"}
18
- :vimeo_ssl:
19
- :url: "https://vimeo.com/31158841"
20
- :body: |
21
- {"type":"video","version":"1.0","provider_name":"Vimeo","provider_url":"https:\/\/vimeo.com\/","title":"Murmuration","author_name":"Islands & Rivers","author_url":"https:\/\/vimeo.com\/islandsandrivers","is_plus":"0","account_type":"basic","html":"<iframe src=\"https:\/\/player.vimeo.com\/video\/31158841?app_id=122963\" width=\"400\" height=\"320\" frameborder=\"0\" allow=\"autoplay; fullscreen\" allowfullscreen title=\"Murmuration\"><\/iframe>","width":400,"height":320,"duration":123,"description":"A chance encounter and shared moment with one of natures greatest and most fleeting phenomena.\n\nFacebook: Islands And Rivers\nFor licensing information contact Dale Dobson - dale@iconiclinx.com","thumbnail_url":"https:\/\/i.vimeocdn.com\/video\/448600816_295x166.jpg","thumbnail_width":295,"thumbnail_height":221,"thumbnail_url_with_play_button":"https:\/\/i.vimeocdn.com\/filter\/overlay?src0=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F448600816_295x166.jpg&src1=http%3A%2F%2Ff.vimeocdn.com%2Fp%2Fimages%2Fcrawler_play.png","upload_date":"2011-10-26 14:43:13","video_id":31158841,"uri":"\/videos\/31158841"}
22
- :rev3:
23
- :url: "http://revision3.com/diggnation/2008-04-17xsanned/"
24
- :hulu:
25
- :url: "http://www.hulu.com/watch/4569/firefly-serenity#x-0,vepisode,1"
26
- :google_video:
27
- :url: "http://video.google.com/videoplay?docid=8372603330420559198"