onebox 1.8.39 → 1.8.40
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 +4 -4
- data/.rubocop.yml +1 -1
- data/.travis.yml +0 -1
- data/README.md +1 -1
- data/lib/onebox/engine/amazon_onebox.rb +98 -17
- data/lib/onebox/version.rb +3 -1
- data/onebox.gemspec +5 -5
- data/templates/amazon.mustache +7 -1
- metadata +7 -177
- data/spec/fixtures/amazon-og.response +0 -3675
- data/spec/fixtures/amazon.response +0 -3040
- data/spec/fixtures/cloudapp-gif.response +0 -66
- data/spec/fixtures/cloudapp-jpg.response +0 -66
- data/spec/fixtures/cloudapp-mp4.response +0 -65
- data/spec/fixtures/cloudapp-others.response +0 -66
- data/spec/fixtures/dailymail.response +0 -5914
- data/spec/fixtures/discourse_topic.response +0 -344
- data/spec/fixtures/discourse_topic_reply.response +0 -345
- data/spec/fixtures/douban.response +0 -4399
- data/spec/fixtures/etsy.response +0 -5827
- data/spec/fixtures/etsy_mobile.response +0 -4230
- data/spec/fixtures/gfycat.response +0 -1
- data/spec/fixtures/githubblob.response +0 -46
- data/spec/fixtures/githubcommit.response +0 -87
- data/spec/fixtures/githubgist.response +0 -310
- data/spec/fixtures/githubpullrequest.response +0 -216
- data/spec/fixtures/googleplayapp.response +0 -138
- data/spec/fixtures/image.response +0 -0
- data/spec/fixtures/meetup.response.html +0 -4419
- data/spec/fixtures/meetup_oembed.response +0 -1
- data/spec/fixtures/pubmed-electronic-xml.response +0 -175
- data/spec/fixtures/pubmed-electronic.response +0 -307
- data/spec/fixtures/pubmed-xml.response +0 -122
- data/spec/fixtures/pubmed.response +0 -300
- data/spec/fixtures/slides.response +0 -2852
- data/spec/fixtures/stackexchange-answer.response +0 -1
- data/spec/fixtures/stackexchange-question.response +0 -1
- data/spec/fixtures/twitterstatus.response +0 -2814
- data/spec/fixtures/video.response +0 -0
- data/spec/fixtures/wechat-mp.response +0 -631
- data/spec/fixtures/wikimedia.response +0 -1
- data/spec/fixtures/wikipedia.response +0 -566
- data/spec/fixtures/wikipediaredirected.response +0 -899
- data/spec/fixtures/xkcd.response +0 -1
- data/spec/fixtures/youku-meta.response +0 -1
- data/spec/fixtures/youku.response +0 -1443
- data/spec/fixtures/youtube-channel.response +0 -5446
- data/spec/fixtures/youtube-json.response +0 -1
- data/spec/fixtures/youtube-list-json.response +0 -1
- data/spec/fixtures/youtube.response +0 -1625
- data/spec/lib/onebox/engine/amazon_onebox_spec.rb +0 -116
- data/spec/lib/onebox/engine/audio_onebox_spec.rb +0 -31
- data/spec/lib/onebox/engine/cloudapp_onebox_spec.rb +0 -26
- data/spec/lib/onebox/engine/douban_onebox_spec.rb +0 -29
- data/spec/lib/onebox/engine/gfycat_onebox_spec.rb +0 -34
- data/spec/lib/onebox/engine/github_blob_onebox_spec.rb +0 -21
- data/spec/lib/onebox/engine/github_commit_onebox_spec.rb +0 -108
- data/spec/lib/onebox/engine/github_gist_onebox_spec.rb +0 -67
- data/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb +0 -46
- data/spec/lib/onebox/engine/google_docs_onebox_spec.rb +0 -35
- data/spec/lib/onebox/engine/google_maps_onebox_spec.rb +0 -72
- data/spec/lib/onebox/engine/google_play_app_onebox_spec.rb +0 -28
- data/spec/lib/onebox/engine/html_spec.rb +0 -25
- data/spec/lib/onebox/engine/image_onebox_spec.rb +0 -39
- data/spec/lib/onebox/engine/json_spec.rb +0 -25
- data/spec/lib/onebox/engine/pdf_onebox_spec.rb +0 -28
- data/spec/lib/onebox/engine/pubmed_onebox_spec.rb +0 -78
- data/spec/lib/onebox/engine/slides_onebox_spec.rb +0 -24
- data/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb +0 -97
- data/spec/lib/onebox/engine/trello_onebox_spec.rb +0 -30
- data/spec/lib/onebox/engine/twitch_clips_onebox_spec.rb +0 -10
- data/spec/lib/onebox/engine/twitch_stream_onebox_spec.rb +0 -15
- data/spec/lib/onebox/engine/twitch_video_onebox_spec.rb +0 -10
- data/spec/lib/onebox/engine/twitter_status_onebox_spec.rb +0 -187
- data/spec/lib/onebox/engine/video_onebox_spec.rb +0 -31
- data/spec/lib/onebox/engine/wechat_mp_onebox_spec.rb +0 -26
- data/spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb +0 -179
- data/spec/lib/onebox/engine/wikimedia_onebox_spec.rb +0 -23
- data/spec/lib/onebox/engine/wikipedia_onebox_spec.rb +0 -21
- data/spec/lib/onebox/engine/xkcd_spec.rb +0 -27
- data/spec/lib/onebox/engine/youku_onebox_spec.rb +0 -13
- data/spec/lib/onebox/engine/youtube_onebox_spec.rb +0 -84
- data/spec/lib/onebox/engine_spec.rb +0 -101
- data/spec/lib/onebox/helpers_spec.rb +0 -73
- data/spec/lib/onebox/layout_spec.rb +0 -79
- data/spec/lib/onebox/matcher_spec.rb +0 -74
- data/spec/lib/onebox/preview_spec.rb +0 -74
- data/spec/lib/onebox/status_check_spec.rb +0 -68
- data/spec/lib/onebox_spec.rb +0 -65
- data/spec/spec_helper.rb +0 -90
- data/spec/support/html_spec_helper.rb +0 -18
- data/web/assets/javascripts/jquery.js +0 -4
- data/web/assets/javascripts/main.js +0 -23
- data/web/assets/stylesheets/normalize.css +0 -427
- data/web/assets/stylesheets/style.css +0 -25
- data/web/views/index.haml +0 -29
- data/web/views/layout.haml +0 -11
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::GoogleDocsOnebox do
|
|
4
|
-
context "Spreadsheets" do
|
|
5
|
-
let(:matcher) { described_class.new("https://docs.google.com/spreadsheets/d/SHEET_KEY/pubhtml") }
|
|
6
|
-
|
|
7
|
-
it "should be a spreadsheet" do
|
|
8
|
-
expect(matcher.send(:shorttype)).to eq (:sheets)
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
context "Documents" do
|
|
13
|
-
let(:matcher) { described_class.new("https://docs.google.com/document/d/DOC_KEY/pub") }
|
|
14
|
-
|
|
15
|
-
it "should be a document" do
|
|
16
|
-
expect(matcher.send(:shorttype)).to eq (:docs)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
context "Presentaions" do
|
|
21
|
-
let(:matcher) { described_class.new("https://docs.google.com/presentation/d/PRESENTATION_KEY/pub") }
|
|
22
|
-
|
|
23
|
-
it "should be a presentation" do
|
|
24
|
-
expect(matcher.send(:shorttype)).to eq (:slides)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
context "Forms" do
|
|
29
|
-
let(:matcher) { described_class.new("https://docs.google.com/forms/d/FORMS_KEY/viewform") }
|
|
30
|
-
|
|
31
|
-
it "should be a form" do
|
|
32
|
-
expect(matcher.send(:shorttype)).to eq (:forms)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::GoogleMapsOnebox do
|
|
4
|
-
|
|
5
|
-
URLS = {
|
|
6
|
-
short: {
|
|
7
|
-
test: "https://goo.gl/maps/rEG3D",
|
|
8
|
-
redirect: ["302 Found", :long],
|
|
9
|
-
expect: "https://maps.google.de/maps?sll=40.689249,-74.0445&sspn=0.0062479,0.0109864&cid=4667599994556318251&q=Statue+of+Liberty+National+Monument&output=embed&dg=ntvb&ll=40.689249,-74.0445&spn=0.0062479,0.0109864",
|
|
10
|
-
},
|
|
11
|
-
long: {
|
|
12
|
-
test: "https://www.google.de/maps/place/Statue+of+Liberty+National+Monument/@40.689249,-74.0445,17z/data=!3m1!4b1!4m2!3m1!1s0x89c25090129c363d:0x40c6a5770d25022b",
|
|
13
|
-
redirect: ["301 Moved Permanently", :canonical],
|
|
14
|
-
expect: "https://maps.google.de/maps?sll=40.689249,-74.0445&sspn=0.0062479,0.0109864&cid=4667599994556318251&q=Statue+of+Liberty+National+Monument&output=embed&dg=ntvb&ll=40.689249,-74.0445&spn=0.0062479,0.0109864",
|
|
15
|
-
},
|
|
16
|
-
canonical: {
|
|
17
|
-
test: "https://maps.google.de/maps?sll=40.689249,-74.0445&sspn=0.0062479,0.0109864&cid=4667599994556318251&q=Statue+of+Liberty+National+Monument&output=classic&dg=ntvb",
|
|
18
|
-
expect: "https://maps.google.de/maps?sll=40.689249,-74.0445&sspn=0.0062479,0.0109864&cid=4667599994556318251&q=Statue+of+Liberty+National+Monument&output=embed&dg=ntvb&ll=40.689249,-74.0445&spn=0.0062479,0.0109864",
|
|
19
|
-
},
|
|
20
|
-
custom: {
|
|
21
|
-
test: "https://www.google.com/maps/d/edit?mid=zPYyZFrHi1MU.kX85W_Y2y2_E",
|
|
22
|
-
expect: "https://www.google.com/maps/d/embed?mid=zPYyZFrHi1MU.kX85W_Y2y2_E",
|
|
23
|
-
},
|
|
24
|
-
streetview: {
|
|
25
|
-
test: "https://www.google.com/maps/@46.414384,10.013947,3a,75y,232.83h,99.08t/data=!3m5!1e1!3m3!1s9WgYUb5quXDjqqFd3DWI6A!2e0!3e5?hl=de",
|
|
26
|
-
expect: "https://www.google.com/maps/embed?pb=!3m2!2sen!4v0!6m8!1m7!1s9WgYUb5quXDjqqFd3DWI6A!2m2!1d46.414384!2d10.013947!3f232.83!4f9.908!5f0.75",
|
|
27
|
-
streetview: true
|
|
28
|
-
},
|
|
29
|
-
unresolveable: {
|
|
30
|
-
test: "https://www.google.com/maps/place/Den+Abattoir/@51.2285173,4.4336702,17z/data=!4m7!1m4!3m3!1s0x47c3f7a5ac48e237:0x63d716018f584a33!2zUGnDqXRyYWlu!3b1!3m1!1s0x0000000000000000:0xfbfac0c41c32471a",
|
|
31
|
-
redirect: ["302 Found", "https://www.google.com/maps/place/Den+Abattoir/@51.2285173,4.4336702,17z/data=!4m7!1m4!3m3!1s0x47c3f7a5ac48e237:0x63d716018f584a33!2zUGnDqXRyYWlu!3b1!3m1!1s0x0000000000000000:0xfbfac0c41c32471a?dg=dbrw&newdg=1"],
|
|
32
|
-
expect: "https://maps.google.com/maps?ll=51.2285173,4.4336702&z=17&output=embed&dg=ntvb&q=Den+Abattoir&cid=18157036796216755994"
|
|
33
|
-
},
|
|
34
|
-
satellite: {
|
|
35
|
-
test: "https://www.google.de/maps/@40.6894264,-74.0449146,758m/data=!3m1!1e3",
|
|
36
|
-
redirect: ["302 Found", "https://www.google.de/maps/@40.6894264,-74.0449146,758m/data=!3m1!1e3?dg=dbrw&newdg=1"],
|
|
37
|
-
expect: "https://maps.google.com/maps?ll=40.6894264,-74.0449146&z=16&output=embed&dg=ntvb"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
# Register URL redirects
|
|
42
|
-
before(:all) do
|
|
43
|
-
URLS.values.each do |t|
|
|
44
|
-
status, location = *t[:redirect]
|
|
45
|
-
location = URLS[location][:test] if location.is_a? Symbol
|
|
46
|
-
FakeWeb.register_uri(:head, t[:test], response: "HTTP/1.1 #{status}\nLocation: #{location}\n\n")
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# Prevent sleep from wasting our time when we test with strange redirects
|
|
51
|
-
subject do
|
|
52
|
-
described_class.send(:allocate).tap do |obj|
|
|
53
|
-
allow(obj).to receive(:sleep)
|
|
54
|
-
obj.send(:initialize, link)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
let(:data) { Onebox::Helpers.symbolize_keys(subject.send(:data)) }
|
|
59
|
-
let(:link) { |example| URLS[example.metadata[:urltype] || :short][:test] }
|
|
60
|
-
|
|
61
|
-
include_context "an engine", urltype: :short
|
|
62
|
-
|
|
63
|
-
URLS.each do |kind, t|
|
|
64
|
-
it "processes #{kind.to_s} url correctly", urltype: kind do
|
|
65
|
-
expect(subject.url).to eq t[:expect]
|
|
66
|
-
expect(subject.streetview?).to t[:streetview] ? be_truthy : be_falsey
|
|
67
|
-
expect(subject.to_html).to include("<iframe")
|
|
68
|
-
expect(subject.placeholder_html).to include("<img")
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::GooglePlayAppOnebox do
|
|
4
|
-
before(:all) do
|
|
5
|
-
@link = "https://play.google.com/store/apps/details?id=com.hulu.plus&hl=en"
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
include_context "engines"
|
|
9
|
-
it_behaves_like "an engine"
|
|
10
|
-
|
|
11
|
-
describe "#to_html" do
|
|
12
|
-
it "has developer" do
|
|
13
|
-
expect(html).to include("Hulu")
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "has image" do
|
|
17
|
-
expect(html).to include("JH08z41G8hlCw=w300-rw")
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "has description" do
|
|
21
|
-
expect(html).to include("Instantly watch current TV shows")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "has price" do
|
|
25
|
-
expect(html).to include("Free")
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::HTML do
|
|
4
|
-
before(:all) do
|
|
5
|
-
@link = "http://amazon.com"
|
|
6
|
-
fake(@link, response("amazon"))
|
|
7
|
-
end
|
|
8
|
-
before(:each) { Onebox.options.cache.clear }
|
|
9
|
-
|
|
10
|
-
describe "#raw" do
|
|
11
|
-
class OneboxEngineHTML
|
|
12
|
-
include Onebox::Engine
|
|
13
|
-
include Onebox::Engine::HTML
|
|
14
|
-
|
|
15
|
-
def initialize(link)
|
|
16
|
-
@url = link
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "returns a Nokogiri object that has a css method" do
|
|
21
|
-
object = OneboxEngineHTML.new("http://amazon.com").send(:raw)
|
|
22
|
-
expect(object).to respond_to(:css)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::ImageOnebox do
|
|
4
|
-
it "supports png" do
|
|
5
|
-
expect(Onebox.preview('http://www.discourse.org/images/logo.png').to_s).to match(/<img/)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it "supports jpg" do
|
|
9
|
-
expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg').to_s).to match(/<img/)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "supports jpeg" do
|
|
13
|
-
expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/en/b/bb/Poster.jpeg').to_s).to match(/<img/)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "supports gif" do
|
|
17
|
-
expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/5/55/Tesseract.gif').to_s).to match(/<img/)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "supports tif" do
|
|
21
|
-
expect(Onebox.preview('http://www.fileformat.info/format/tiff/sample/1f37bbd5603048178487ec88b1a6425b/MARBLES.tif').to_s).to match(/<img/)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "supports bmp" do
|
|
25
|
-
expect(Onebox.preview('http://www.fileformat.info/format/bmp/sample/d4202a5fc22a48c388d9e1c636792cc6/LAND.BMP').to_s).to match(/<img/)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "supports image URLs with query parameters" do
|
|
29
|
-
expect(Onebox.preview('https://www.google.com/logos/doodles/2014/percy-julians-115th-birthday-born-1899-5688801926053888-hp.jpg?foo=bar').to_s).to match(/<img/)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "supports protocol relative image URLs" do
|
|
33
|
-
expect(Onebox.preview('//www.google.com/logos/doodles/2014/percy-julians-115th-birthday-born-1899-5688801926053888-hp.jpg').to_s).to match(/<img/)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "includes a direct link to the image" do
|
|
37
|
-
expect(Onebox.preview('http://www.discourse.org/images/logo.png').to_s).to match(/<a.*png/)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::JSON do
|
|
4
|
-
before(:all) do
|
|
5
|
-
@link = "http://stackoverflow.com"
|
|
6
|
-
fake(@link, response("stackexchange-question"))
|
|
7
|
-
end
|
|
8
|
-
before(:each) { Onebox.options.cache.clear }
|
|
9
|
-
|
|
10
|
-
describe "#raw" do
|
|
11
|
-
class OneboxEngineJSON
|
|
12
|
-
include Onebox::Engine
|
|
13
|
-
include Onebox::Engine::JSON
|
|
14
|
-
|
|
15
|
-
def initialize(link)
|
|
16
|
-
@url = link
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "returns a hash" do
|
|
21
|
-
object = OneboxEngineJSON.new(@link).send(:raw)
|
|
22
|
-
expect(object).to be_a(Hash)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::PdfOnebox do
|
|
4
|
-
let(:link) { "https://acrobatusers.com/assets/uploads/public_downloads/2217/adobe-acrobat-xi-merge-pdf-files-tutorial-ue.pdf" }
|
|
5
|
-
let(:html) { described_class.new(link).to_html }
|
|
6
|
-
|
|
7
|
-
let(:no_content_length_link) { "https://dspace.lboro.ac.uk/dspace-jspui/bitstream/2134/14294/3/greiffenhagen-ca_and_consumption.pdf" }
|
|
8
|
-
let(:no_filesize_html) { described_class.new(no_content_length_link).to_html }
|
|
9
|
-
|
|
10
|
-
before do
|
|
11
|
-
FakeWeb.register_uri(:head, link, content_length: "335562")
|
|
12
|
-
FakeWeb.register_uri(:head, no_content_length_link, content_length: nil)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe "#to_html" do
|
|
16
|
-
it "includes filename" do
|
|
17
|
-
expect(html).to include("adobe-acrobat-xi-merge-pdf-files-tutorial-ue.pdf")
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "includes filesize" do
|
|
21
|
-
expect(html).to include("327.70 KB")
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "doesn’t include filesize when unknown" do
|
|
25
|
-
expect(no_filesize_html).to_not include("<p class='filesize'>")
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::PubmedOnebox do
|
|
4
|
-
|
|
5
|
-
let(:link) { "http://www.ncbi.nlm.nih.gov/pubmed/7288891" }
|
|
6
|
-
let(:xml_link) { "http://www.ncbi.nlm.nih.gov/pubmed/7288891?report=xml&format=text" }
|
|
7
|
-
let(:html) { described_class.new(link).to_html }
|
|
8
|
-
|
|
9
|
-
before do
|
|
10
|
-
fake(link, response("pubmed"))
|
|
11
|
-
fake(xml_link, response("pubmed-xml"))
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "has the paper's title" do
|
|
15
|
-
expect(html).to include("Evolutionary trees from DNA sequences: a maximum likelihood approach.")
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "has the paper's author" do
|
|
19
|
-
expect(html).to include("Felsenstein")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "has the paper's abstract" do
|
|
23
|
-
expect(html).to include("The application of maximum likelihood techniques to the estimation of evolutionary trees from nucleic acid sequence data is discussed.") end
|
|
24
|
-
|
|
25
|
-
it "has the paper's date" do
|
|
26
|
-
expect(html).to include("1981")
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "has the URL to the resource" do
|
|
30
|
-
expect(html).to include(link)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "Pubmed electronic print" do
|
|
34
|
-
let(:link) { "http://www.ncbi.nlm.nih.gov/pubmed/24737116" }
|
|
35
|
-
let(:xml_link) { "http://www.ncbi.nlm.nih.gov/pubmed/24737116?report=xml&format=text" }
|
|
36
|
-
let(:html) { described_class.new(link).to_html }
|
|
37
|
-
|
|
38
|
-
before do
|
|
39
|
-
fake(link, response("pubmed-electronic"))
|
|
40
|
-
fake(xml_link, response("pubmed-electronic-xml"))
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "has the paper's title" do
|
|
44
|
-
expect(html).to include("Cushingoid facies on (18)F-FDG PET/CT.")
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "has the paper's author" do
|
|
48
|
-
expect(html).to include("van Rheenen")
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "has the paper's date" do
|
|
52
|
-
expect(html).to include("Jul 2014")
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "has the URL to the resource" do
|
|
56
|
-
expect(html).to include(link)
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context "regex URI match" do
|
|
61
|
-
|
|
62
|
-
it "matches on specific articles" do
|
|
63
|
-
expect(match("http://www.ncbi.nlm.nih.gov/pubmed/7288891")).to eq true
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it "does not match on search" do
|
|
67
|
-
expect(match("http://www.ncbi.nlm.nih.gov/pubmed/?term=rheenen+r")).to eq false
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "does not match on the root" do
|
|
71
|
-
expect(match("http://www.ncbi.nlm.nih.gov/pubmed/")).to eq false
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
def match(url)
|
|
75
|
-
Onebox::Engine::PubmedOnebox === URI(url)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::SlidesOnebox do
|
|
4
|
-
|
|
5
|
-
let(:link) { "http://slides.com/drksephy/ecmascript-2015" }
|
|
6
|
-
let(:html) { described_class.new(link).to_html }
|
|
7
|
-
|
|
8
|
-
before do
|
|
9
|
-
fake(link, response("slides"))
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "#placeholder_html" do
|
|
13
|
-
it "returns an image as the placeholder" do
|
|
14
|
-
expect(Onebox.preview(link).placeholder_html).to include("//s3.amazonaws.com/media-p.slid.es/thumbnails/secure/cff7c3/decks.jpg")
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
describe "#to_html" do
|
|
19
|
-
it "returns iframe embed" do
|
|
20
|
-
expect(html).to include(URI(link).path)
|
|
21
|
-
expect(html).to include("iframe")
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Onebox::Engine::StackExchangeOnebox do
|
|
4
|
-
describe 'domains' do
|
|
5
|
-
[
|
|
6
|
-
'stackoverflow.com', 'meta.stackoverflow.com',
|
|
7
|
-
'superuser.com', 'meta.superuser.com',
|
|
8
|
-
'serverfault.com', 'meta.serverfault.com',
|
|
9
|
-
'askubuntu.com', 'meta.askubuntu.com',
|
|
10
|
-
'mathoverflow.net', 'meta.mathoverflow.net',
|
|
11
|
-
'money.stackexchange.com', 'meta.money.stackexchange.com',
|
|
12
|
-
'stackapps.com'
|
|
13
|
-
].each do |domain|
|
|
14
|
-
it "matches question with short URL on #{domain}" do
|
|
15
|
-
expect(described_class === URI("http://#{domain}/q/55495")).to eq(true)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "matches question with long URL on #{domain}" do
|
|
19
|
-
expect(described_class === URI("http://#{domain}/questions/55495/title-of-question")).to eq(true)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "matches answer with short URL on #{domain}" do
|
|
23
|
-
expect(described_class === URI("http://#{domain}/a/55503")).to eq(true)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "matches question with long URL on #{domain}" do
|
|
27
|
-
expect(described_class === URI("http://#{domain}/questions/55495/title-of-question/55503#55503")).to eq(true)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "doesn't match question on example.com" do
|
|
32
|
-
expect(described_class === URI('http://example.com/q/4711')).to eq(false)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "doesn't match answer on example.com" do
|
|
36
|
-
expect(described_class === URI('http://example.com/a/4711')).to eq(false)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
'long URL' => 'http://stackoverflow.com/questions/17992553/concept-behind-these-four-lines-of-tricky-c-code',
|
|
42
|
-
'short URL' => 'http://stackoverflow.com/q/17992553'
|
|
43
|
-
}.each do |name, url|
|
|
44
|
-
describe "question with #{name}" do
|
|
45
|
-
before(:all) do
|
|
46
|
-
@link = url
|
|
47
|
-
fake('https://api.stackexchange.com/2.2/questions/17992553?site=stackoverflow.com&filter=!5-duuxrJa-iw9oVvOA(JNimB5VIisYwZgwcfNI', response('stackexchange-question'))
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
include_context 'engines'
|
|
51
|
-
it_behaves_like 'an engine'
|
|
52
|
-
|
|
53
|
-
describe '#to_html' do
|
|
54
|
-
it 'includes question title' do
|
|
55
|
-
expect(html).to include('Concept behind these four lines of tricky C code')
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
it "includes 'asked by'" do
|
|
59
|
-
expect(html).to include('asked by')
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "doesn't include 'answered by'" do
|
|
63
|
-
expect(html).not_to include('answered by')
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
'long URL' => 'http://stackoverflow.com/questions/17992553/concept-behind-these-four-lines-of-tricky-c-code/17992906#17992906',
|
|
71
|
-
'short URL' => 'http://stackoverflow.com/a/17992906'
|
|
72
|
-
}.each do |name, url|
|
|
73
|
-
describe "answer with #{name}" do
|
|
74
|
-
before(:all) do
|
|
75
|
-
@link = url
|
|
76
|
-
fake('https://api.stackexchange.com/2.2/answers/17992906?site=stackoverflow.com&filter=!.FjueITQdx6-Rq3Ue9PWG.QZ2WNdW', response('stackexchange-answer'))
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
include_context 'engines'
|
|
80
|
-
it_behaves_like 'an engine'
|
|
81
|
-
|
|
82
|
-
describe '#to_html' do
|
|
83
|
-
it 'includes question title' do
|
|
84
|
-
expect(html).to include('Concept behind these four lines of tricky C code')
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it "includes 'answered by'" do
|
|
88
|
-
expect(html).to include('answered by')
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it "doesn't include 'asked by'" do
|
|
92
|
-
expect(html).not_to include('asked by')
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|