onebox 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +4 -0
- data/.travis.yml +4 -0
- data/README.md +154 -113
- data/lib/onebox.rb +6 -3
- data/lib/onebox/engine.rb +28 -26
- data/lib/onebox/engine/amazon_onebox.rb +4 -2
- data/lib/onebox/engine/bliptv_onebox.rb +4 -2
- data/lib/onebox/engine/clikthrough_onebox.rb +4 -2
- data/lib/onebox/engine/college_humor_onebox.rb +3 -2
- data/lib/onebox/engine/dailymotion_onebox.rb +4 -2
- data/lib/onebox/engine/dotsub_onebox.rb +4 -2
- data/lib/onebox/engine/example_onebox.rb +4 -5
- data/lib/onebox/engine/flickr_onebox.rb +3 -2
- data/lib/onebox/engine/funny_or_die_onebox.rb +4 -2
- data/lib/onebox/engine/github_blob_onebox.rb +28 -0
- data/lib/onebox/engine/github_commit_onebox.rb +43 -0
- data/lib/onebox/engine/github_gist_onebox.rb +33 -0
- data/lib/onebox/engine/github_pullrequest_onebox.rb +43 -0
- data/lib/onebox/engine/html.rb +1 -1
- data/lib/onebox/engine/hulu_onebox.rb +5 -2
- data/lib/onebox/engine/imgur_image_onebox.rb +26 -0
- data/lib/onebox/engine/itunes_onebox.rb +28 -0
- data/lib/onebox/engine/json.rb +11 -0
- data/lib/onebox/engine/kinomap_onebox.rb +27 -0
- data/lib/onebox/engine/nfb_onebox.rb +5 -2
- data/lib/onebox/engine/open_graph.rb +1 -1
- data/lib/onebox/engine/qik_onebox.rb +4 -2
- data/lib/onebox/engine/revision3_onebox.rb +3 -2
- data/lib/onebox/engine/slideshare_onebox.rb +4 -2
- data/lib/onebox/engine/sound_cloud_onebox.rb +4 -2
- data/lib/onebox/engine/spotify_onebox.rb +27 -0
- data/lib/onebox/engine/stack_exchange_onebox.rb +4 -2
- data/lib/onebox/engine/ted_onebox.rb +5 -2
- data/lib/onebox/engine/twitter_onebox.rb +31 -0
- data/lib/onebox/engine/viddler_onebox.rb +5 -3
- data/lib/onebox/engine/vimeo_onebox.rb +3 -2
- data/lib/onebox/engine/wikipedia_onebox.rb +4 -2
- data/lib/onebox/engine/yfrog_onebox.rb +5 -2
- data/lib/onebox/version.rb +1 -1
- data/lib/onebox/view.rb +21 -0
- data/onebox.gemspec +1 -1
- data/spec/fixtures/githubblob.response +922 -0
- data/spec/fixtures/githubcommit.response +87 -0
- data/spec/fixtures/githubgist.response +468 -0
- data/spec/fixtures/githubpullrequest.response +216 -0
- data/spec/fixtures/imguralbum.response +941 -0
- data/spec/fixtures/{imgur.response → imgurimage.response} +870 -890
- data/spec/fixtures/itunes.response +402 -0
- data/spec/fixtures/{rottentomatoes_fresh.response → rottentomatoesfresh.response} +0 -0
- data/spec/fixtures/{rottentomatoes_incomplete.response → rottentomatoesincomplete.response} +0 -0
- data/spec/fixtures/{rottentomatoes_rotten.response → rottentomatoesrotten.response} +0 -0
- data/spec/fixtures/spotify.response +250 -0
- data/spec/fixtures/{wikipedia_redirected.response → wikipediaredirected.response} +0 -0
- data/spec/lib/onebox/engine/{amazon_spec.rb → amazon_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{bliptv_spec.rb → bliptv_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{clikthrough_spec.rb → clikthrough_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{college_humor_spec.rb → college_humor_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{dailymotion_spec.rb → dailymotion_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{dotsub_spec.rb → dotsub_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/example_onebox_spec.rb +21 -0
- data/spec/lib/onebox/engine/{flickr_spec.rb → flickr_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{funny_or_die_spec.rb → funny_or_die_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/github_blob_onebox_spec.rb +30 -0
- data/spec/lib/onebox/engine/github_commit_onebox_spec.rb +61 -0
- data/spec/lib/onebox/engine/github_gist_onebox_spec.rb +29 -0
- data/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb +58 -0
- data/spec/lib/onebox/engine/html_spec.rb +27 -0
- data/spec/lib/onebox/engine/{hulu_spec.rb → hulu_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/imgur_image_onebox_spec.rb +29 -0
- data/spec/lib/onebox/engine/itunes_onebox_spec.rb +29 -0
- data/spec/lib/onebox/engine/json_spec.rb +27 -0
- data/spec/lib/onebox/engine/kinomap_onebox_spec.rb +37 -0
- data/spec/lib/onebox/engine/{nfb_spec.rb → nfb_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/open_graph_spec.rb +27 -0
- data/spec/lib/onebox/engine/{qik_spec.rb → qik_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{revision3_spec.rb → revision3_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{slideshare_spec.rb → slideshare_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{sound_cloud_spec.rb → sound_cloud_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/spotify_onebox_spec.rb +36 -0
- data/spec/lib/onebox/engine/{stack_exchange_spec.rb → stack_exchange_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{ted_spec.rb → ted_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/twitter_onebox_spec.rb +47 -0
- data/spec/lib/onebox/engine/{viddler_spec.rb → viddler_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{vimeo_spec.rb → vimeo_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{wikipedia_spec.rb → wikipedia_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine/{yfrog_spec.rb → yfrog_onebox_spec.rb} +7 -4
- data/spec/lib/onebox/engine_spec.rb +38 -27
- data/spec/lib/onebox/preview_spec.rb +3 -1
- data/spec/lib/onebox/view_spec.rb +16 -0
- data/spec/lib/onebox_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -3
- data/spec/support/html_spec_helper.rb +1 -1
- data/templates/_layout.mustache +4 -0
- data/templates/amazon.mustache +5 -0
- data/templates/bliptv.mustache +5 -0
- data/templates/clikthrough.mustache +4 -0
- data/templates/collegehumor.mustache +5 -0
- data/templates/dailymotion.mustache +5 -0
- data/templates/dotsub.mustache +5 -0
- data/templates/example.mustache +2 -0
- data/templates/flickr.mustache +4 -0
- data/templates/funnyordie.mustache +6 -0
- data/templates/githubblob.mustache +5 -0
- data/templates/githubcommit.mustache +11 -0
- data/templates/githubgist.mustache +3 -0
- data/templates/githubpullrequest.mustache +14 -0
- data/templates/hulu.mustache +6 -0
- data/templates/imgurimage.mustache +3 -0
- data/templates/itunes.mustache +4 -0
- data/templates/kinomap.mustache +5 -0
- data/templates/nfb.mustache +5 -0
- data/templates/qik.mustache +4 -0
- data/templates/revision3.mustache +5 -0
- data/templates/slideshare.mustache +4 -0
- data/templates/soundcloud.mustache +5 -0
- data/templates/spotify.mustache +4 -0
- data/templates/stackexchange.mustache +3 -0
- data/templates/ted.mustache +5 -0
- data/templates/twitter.mustache +7 -0
- data/templates/viddler.mustache +5 -0
- data/templates/vimeo.mustache +5 -0
- data/templates/wikipedia.mustache +4 -0
- data/templates/yfrog.mustache +4 -0
- metadata +139 -90
- data/spec/fixtures/apple.response +0 -391
- data/spec/fixtures/clickthrough.response +0 -1472
- data/spec/fixtures/gist.response +0 -282
- data/spec/fixtures/github_blob.response +0 -706
- data/spec/fixtures/github_commit.response +0 -881
- data/spec/fixtures/github_pullrequest.response +0 -1619
- data/spec/lib/onebox/engine/example_spec.rb +0 -18
- data/templates/amazon.handlebars +0 -9
- data/templates/bliptv.handlebars +0 -10
- data/templates/clickthrough.handlebars +0 -8
- data/templates/clikthrough.handlebars +0 -8
- data/templates/collegehumor.handlebars +0 -9
- data/templates/dailymotion.handlebars +0 -9
- data/templates/dotsub.handlebars +0 -9
- data/templates/flickr.handlebars +0 -8
- data/templates/funnyordie.handlebars +0 -9
- data/templates/hulu.handlebars +0 -9
- data/templates/nfb.handlebars +0 -8
- data/templates/qik.handlebars +0 -7
- data/templates/revision3.handlebars +0 -9
- data/templates/slideshare.handlebars +0 -8
- data/templates/soundcloud.handlebars +0 -9
- data/templates/stackexchange.handlebars +0 -7
- data/templates/ted.handlebars +0 -8
- data/templates/viddler.handlebars +0 -9
- data/templates/vimeo.handlebars +0 -9
- data/templates/wikipedia.handlebars +0 -8
- data/templates/yfrog.handlebars +0 -8
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Onebox::Engine::ItunesOnebox do
|
4
|
+
before(:all) do
|
5
|
+
@link = "https://itunes.apple.com/us/app/minecraft-pocket-edition/id479516143?mt=8"
|
6
|
+
fake(@link, response("itunes"))
|
7
|
+
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
9
|
+
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
13
|
+
|
14
|
+
describe "#to_html" do
|
15
|
+
let(:html) { described_class.new(link).to_html }
|
16
|
+
|
17
|
+
it "returns the product title" do
|
18
|
+
expect(html).to include("Minecraft – Pocket Edition")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns the product image" do
|
22
|
+
expect(html).to include("bxerxqln.png")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns the product description" do
|
26
|
+
expect(html).to include("Get Minecraft – Pocket Edition on the App Store.")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Onebox::Engine::JSON do
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://gist.github.com"
|
6
|
+
fake(@link, response("githubgist"))
|
7
|
+
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
9
|
+
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
describe "#raw" do
|
13
|
+
class OneboxEngineJSON
|
14
|
+
include Onebox::Engine
|
15
|
+
include Onebox::Engine::JSON
|
16
|
+
|
17
|
+
def initialize(link)
|
18
|
+
@url = link
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns a hash" do
|
23
|
+
object = OneboxEngineJSON.new("http://gist.github.com").send(:raw)
|
24
|
+
expect(object).to be_a(Hash)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Onebox::Engine::KinomapOnebox do
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://www.kinomap.com/watch/52wjcu"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
|
+
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
9
|
+
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
13
|
+
|
14
|
+
describe "#to_html" do
|
15
|
+
let(:html) { described_class.new(link).to_html }
|
16
|
+
|
17
|
+
it "returns video title" do
|
18
|
+
expect(html).to include("Enduro Jeunes Touquet - Nicolas Letévé")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "returns video photo" do
|
22
|
+
expect(html).to include("52wjcu_320x240.jpg")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "returns video description" do
|
26
|
+
expect(html).to include("A partir du parc moto,")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns video URL" do
|
30
|
+
expect(html).to include("http://v2.kinomap.com/embed/52wjcu")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns URL" do
|
34
|
+
expect(html).to include(link)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::NFBOnebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://www.nfb.ca/film/overdose"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Onebox::Engine::OpenGraph do
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://flickr.com"
|
6
|
+
fake(@link, response("flickr"))
|
7
|
+
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
9
|
+
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
describe "#raw" do
|
13
|
+
class OneboxEngineOpenGraph
|
14
|
+
include Onebox::Engine
|
15
|
+
include Onebox::Engine::OpenGraph
|
16
|
+
|
17
|
+
def initialize(link)
|
18
|
+
@url = link
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns a OpenGraph object that has a metadata method" do
|
23
|
+
object = OneboxEngineOpenGraph.new("http://flickr.com").send(:raw)
|
24
|
+
expect(object).to respond_to(:metadata)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::QikOnebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://qik.com/video/13430626"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::Revision3Onebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://revision3.com/discoverysharks/blue-sharks"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::SlideshareOnebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://www.slideshare.net/TravelWorldPassport/12-local-traditions"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::SoundCloudOnebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "https://soundcloud.com/rac/penguin-prison-worse-it-gets-rac-mix"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Onebox::Engine::SpotifyOnebox do
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://open.spotify.com/album/3eEtlM70GU40OyHMotY15N"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
|
+
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
9
|
+
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
13
|
+
|
14
|
+
describe "#to_html" do
|
15
|
+
let(:html) { described_class.new(link).to_html }
|
16
|
+
|
17
|
+
it "returns album title" do
|
18
|
+
title = "Keep Moving Forward EP"
|
19
|
+
expect(html).to include(title)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns album description" do
|
23
|
+
description = "Keep Moving Forward EP, an album by Bubble on Spotify"
|
24
|
+
expect(html).to include(description)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "returns album image" do
|
28
|
+
image = "http://o.scdn.co/image/d2c3de070317af4aae4e03daa976690431f1849d"
|
29
|
+
expect(html).to include(image)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns URL" do
|
33
|
+
expect(html).to include(link)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::StackExchangeOnebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://stackoverflow.com/questions/17992553/concept-behind-these-four-lines-of-tricky-c-code"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::TedOnebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://www.ted.com/talks/eli_beer_the_fastest_ambulance_a_motorcycle.html"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Onebox::Engine::TwitterOnebox do
|
4
|
+
before(:all) do
|
5
|
+
@link = "https://twitter.com/toastergrrl/status/363116819147538433"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
|
+
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
9
|
+
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
13
|
+
|
14
|
+
describe "#to_html" do
|
15
|
+
let(:html) { described_class.new(link).to_html }
|
16
|
+
|
17
|
+
it "has tweet text" do
|
18
|
+
expect(html).to include("I'm a sucker for pledges.")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "has tweet time and date" do
|
22
|
+
expect(html).to include("6:59 PM - 1 Aug 13")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has user name" do
|
26
|
+
expect(html).to include("@toastergrrl")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "has user avatar" do
|
30
|
+
expect(html).to include("39b969d32a10b2437563e246708c8f9d_normal.jpeg")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "has tweet favorite count" do
|
34
|
+
pending
|
35
|
+
expect(html).to include("")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "has retweet count" do
|
39
|
+
pending
|
40
|
+
expect(html).to include("")
|
41
|
+
end
|
42
|
+
|
43
|
+
it "has URL" do
|
44
|
+
expect(html).to include(link)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::ViddlerOnebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://www.viddler.com/v/7164f749"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::VimeoOnebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://vimeo.com/70437049"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::WikipediaOnebox do
|
4
|
-
|
5
|
-
|
6
|
-
fake(link, response(
|
4
|
+
before(:all) do
|
5
|
+
@link = "http://en.wikipedia.org/wiki/Kevin_Bacon"
|
6
|
+
fake(@link, response(described_class.template_name))
|
7
7
|
end
|
8
|
+
before(:each) { Onebox.defaults.cache.clear }
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -1,12 +1,15 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Onebox::Engine::YfrogOnebox do
|
4
|
-
|
5
|
-
before do
|
6
|
-
|
4
|
+
before(:each) { Onebox.defaults.cache.clear }
|
5
|
+
before(:all) do
|
6
|
+
@link = "http://twitter.yfrog.com/h0jjdobj?sa=0"
|
7
|
+
fake(@link, response(described_class.template_name))
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
+
let(:link) { @link }
|
11
|
+
|
12
|
+
it_behaves_like "an engine"
|
10
13
|
|
11
14
|
describe "#to_html" do
|
12
15
|
let(:html) { described_class.new(link).to_html }
|
@@ -11,8 +11,10 @@ class OneboxEngineExample
|
|
11
11
|
{ key: "value" }
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
|
14
|
+
def view
|
15
|
+
@view.tap do |layout|
|
16
|
+
layout.view.template = %|<div class="onebox"><a href="{{url}}"></a></div>|
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
@@ -30,7 +32,7 @@ describe Onebox::Engine do
|
|
30
32
|
end
|
31
33
|
|
32
34
|
describe "#record" do
|
33
|
-
class
|
35
|
+
class OneboxEngineRecord
|
34
36
|
include Onebox::Engine
|
35
37
|
|
36
38
|
def data
|
@@ -40,49 +42,58 @@ describe Onebox::Engine do
|
|
40
42
|
|
41
43
|
it "returns cached value for given url if its url is already in cache" do
|
42
44
|
cache = { "http://example.com" => "old content" }
|
43
|
-
result =
|
45
|
+
result = OneboxEngineRecord.new("http://example.com", cache).send(:record)
|
44
46
|
expect(result).to eq("old content")
|
45
47
|
end
|
46
48
|
|
47
49
|
it "stores cache value for given url if cache key doesn't exist" do
|
48
50
|
cache = { "http://example.com1" => "old content" }
|
49
|
-
result =
|
51
|
+
result = OneboxEngineRecord.new("http://example.com", cache).send(:record)
|
50
52
|
expect(result).to eq("new content")
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
|
-
describe "#template_path" do
|
55
|
-
it "returns file path for onebox template" do
|
56
|
-
class OneboxEngineVoo
|
57
|
-
include Onebox::Engine
|
58
|
-
end
|
59
|
-
result = OneboxEngineVoo.new("http://amazon.com").send(:template_path)
|
60
|
-
expect(result).to eq("/home/jzeta/Projects/rgsoc/onebox/templates/enginevoo.handlebars")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
56
|
describe ".===" do
|
57
|
+
class OneboxEngineTripleEqual
|
58
|
+
include Onebox::Engine
|
59
|
+
@@matcher = /example/
|
60
|
+
end
|
65
61
|
it "returns true if argument matches the matcher" do
|
66
|
-
|
67
|
-
include Onebox::Engine
|
68
|
-
@@matcher = /example/
|
69
|
-
end
|
70
|
-
result = OneboxEngineFoo === "http://www.example.com/product/5?var=foo&bar=5"
|
62
|
+
result = OneboxEngineTripleEqual === "http://www.example.com/product/5?var=foo&bar=5"
|
71
63
|
expect(result).to eq(true)
|
72
64
|
end
|
73
65
|
end
|
74
66
|
|
75
67
|
describe ".matches" do
|
68
|
+
class OneboxEngineMatches
|
69
|
+
include Onebox::Engine
|
70
|
+
|
71
|
+
matches do
|
72
|
+
find "foo.com"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
76
|
it "sets @@matcher to a regular expression" do
|
77
|
-
|
78
|
-
|
77
|
+
regex = OneboxEngineMatches.class_variable_get(:@@matcher)
|
78
|
+
expect(regex).to be_a(Regexp)
|
79
|
+
end
|
80
|
+
end
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
-
|
82
|
+
describe ".template_name" do
|
83
|
+
module ScopeForTemplateName
|
84
|
+
class TemplateNameOnebox
|
85
|
+
include Onebox::Engine
|
83
86
|
end
|
84
|
-
|
85
|
-
|
87
|
+
end
|
88
|
+
|
89
|
+
let(:template_name) { ScopeForTemplateName::TemplateNameOnebox.template_name }
|
90
|
+
|
91
|
+
it "should not include the scope" do
|
92
|
+
expect(template_name).not_to include("ScopeForTemplateName", "scopefortemplatename")
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should not include the word Onebox" do
|
96
|
+
expect(template_name).not_to include("onebox", "Onebox")
|
86
97
|
end
|
87
98
|
end
|
88
99
|
end
|