onebox 1.8.39 → 1.8.40
Sign up to get free protection for your applications and to get access to all the features.
- 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,116 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::AmazonOnebox do
|
4
|
-
|
5
|
-
context "regular amazon page" do
|
6
|
-
before do
|
7
|
-
@link = "https://www.amazon.com/Knit-Noro-Accessories-Colorful-Little/dp/193609620X"
|
8
|
-
@uri = "https://www.amazon.com/gp/aw/d/193609620X"
|
9
|
-
end
|
10
|
-
include_context "engines"
|
11
|
-
it_behaves_like "an engine"
|
12
|
-
|
13
|
-
describe "works with international domains" do
|
14
|
-
|
15
|
-
def check_link(tdl, link)
|
16
|
-
onebox_cls = Onebox::Matcher.new(link).oneboxed
|
17
|
-
expect(onebox_cls).to_not be(nil)
|
18
|
-
expect(onebox_cls.new(link).url).to include("https://www.amazon.#{tdl}")
|
19
|
-
end
|
20
|
-
|
21
|
-
it "matches canadian domains" do
|
22
|
-
check_link("ca", "https://www.amazon.ca/Too-Much-Happiness-Alice-Munro-ebook/dp/B0031TZ98K/")
|
23
|
-
end
|
24
|
-
|
25
|
-
it "matches german domains" do
|
26
|
-
check_link("de", "https://www.amazon.de/Buddenbrooks-Verfall-einer-Familie-Roman/dp/3596294312/")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "matches uk domains" do
|
30
|
-
check_link("co.uk", "https://www.amazon.co.uk/Pygmalion-George-Bernard-Shaw/dp/1420925237/")
|
31
|
-
end
|
32
|
-
|
33
|
-
it "matches japanese domains" do
|
34
|
-
check_link("co.jp", "https://www.amazon.co.jp/%E9%9B%AA%E5%9B%BD-%E6%96%B0%E6%BD%AE%E6%96%87%E5%BA%AB-%E3%81%8B-1-1-%E5%B7%9D%E7%AB%AF-%E5%BA%B7%E6%88%90/dp/4101001014/")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "matches chinese domains" do
|
38
|
-
check_link("cn", "https://www.amazon.cn/%E5%AD%99%E5%AD%90%E5%85%B5%E6%B3%95-%E5%AD%99%E8%86%91%E5%85%B5%E6%B3%95-%E5%AD%99%E6%AD%A6/dp/B0011C40FC/")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "matches french domains" do
|
42
|
-
check_link("fr", "https://www.amazon.fr/Les-Mots-autres-%C3%A9crits-autobiographiques/dp/2070114147/")
|
43
|
-
end
|
44
|
-
|
45
|
-
it "matches italian domains" do
|
46
|
-
check_link("it", "https://www.amazon.it/Tutte-poesie-Salvatore-Quasimodo/dp/8804520477/")
|
47
|
-
end
|
48
|
-
|
49
|
-
it "matches spanish domains" do
|
50
|
-
check_link("es", "https://www.amazon.es/familia-Pascual-Duarte-Camilo-Jos%C3%A9-ebook/dp/B00EJRTKTW/")
|
51
|
-
end
|
52
|
-
|
53
|
-
it "matches brasilian domains" do
|
54
|
-
check_link("com.br", "https://www.amazon.com.br/A-p%C3%A1tria-chuteiras-Nelson-Rodrigues-ebook/dp/B00J2B414Y/")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "matches indian domains" do
|
58
|
-
check_link("in", "https://www.amazon.in/Fireflies-Rabindranath-Tagore/dp/9381523169/")
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "#url" do
|
64
|
-
it "maintains the same http/https scheme as the requested URL" do
|
65
|
-
expect(described_class.new("https://www.amazon.fr/gp/product/B01BYD0TZM").url)
|
66
|
-
.to eq("https://www.amazon.fr/gp/aw/d/B01BYD0TZM")
|
67
|
-
|
68
|
-
expect(described_class.new("http://www.amazon.fr/gp/product/B01BYD0TZM").url)
|
69
|
-
.to eq("https://www.amazon.fr/gp/aw/d/B01BYD0TZM")
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#to_html" do
|
74
|
-
it "includes image" do
|
75
|
-
expect(html).to include("http://ecx.images-amazon.com/images/I/51opYcR6kVL._SY400_.jpg")
|
76
|
-
end
|
77
|
-
|
78
|
-
it "includes description" do
|
79
|
-
expect(html).to include("I have been programming for 25 years in a variety of hardware and software languages.")
|
80
|
-
end
|
81
|
-
|
82
|
-
it "includes price" do
|
83
|
-
expect(html).to include("$25.34")
|
84
|
-
end
|
85
|
-
|
86
|
-
it "includes title" do
|
87
|
-
expect(html).to include("Seven Languages in Seven Weeks: A Pragmatic Guide to Learning Programming Languages (Pragmatic Programmers)")
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context "amazon with opengraph" do
|
93
|
-
let(:link) { "https://www.amazon.com/dp/B01MFXN4Y2" }
|
94
|
-
let(:html) { described_class.new(link).to_html }
|
95
|
-
|
96
|
-
before do
|
97
|
-
fake("https://www.amazon.com/gp/aw/d/B01MFXN4Y2", response("amazon-og"))
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "#to_html" do
|
101
|
-
it "includes image" do
|
102
|
-
expect(html).to include("https://images-na.ssl-images-amazon.com/images/I/51nOF2iBa6L._SX940_.jpg")
|
103
|
-
end
|
104
|
-
|
105
|
-
it "includes description" do
|
106
|
-
expect(html).to include("CHRISTINE is the story of an aspiring newswoman caught in the midst of a personal and professional life crisis. Between unrequited love, frustration at work, a tumultuous home, and self-doubt; she begins to spiral down a dark path.")
|
107
|
-
end
|
108
|
-
|
109
|
-
it "includes title" do
|
110
|
-
expect(html).to include("Watch Christine online - Amazon Video")
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::AudioOnebox do
|
4
|
-
it "supports ogg" do
|
5
|
-
expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg').to_s).to match(/<audio/)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "supports mp3" do
|
9
|
-
expect(Onebox.preview('http://kolber.github.io/audiojs/demos/mp3/juicy.MP3').to_s).to match(/<audio/)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "supports wav" do
|
13
|
-
expect(Onebox.preview('http://download.wavetlan.com/SVV/Media/HTTP/sample14.wav').to_s).to match(/<audio/)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "supports m4a" do
|
17
|
-
expect(Onebox.preview('http://techslides.com/demos/samples/sample.m4a').to_s).to match(/<audio/)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "supports URLs with query parameters" do
|
21
|
-
expect(Onebox.preview('https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg?foo=bar').to_s).to match(/<audio/)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "supports protocol relative URLs" do
|
25
|
-
expect(Onebox.preview('//upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg').to_s).to match(/<audio/)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "includes a fallback direct link to the audio" do
|
29
|
-
expect(Onebox.preview('http://kolber.github.io/audiojs/demos/mp3/juicy.mp3').to_s).to match(/<a.*mp3/)
|
30
|
-
end
|
31
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::CloudAppOnebox do
|
4
|
-
before do
|
5
|
-
fake("https://cl.ly/0m2a2u2k440O", response("cloudapp-gif"))
|
6
|
-
fake("https://cl.ly/0T0c2J3S373X", response("cloudapp-mp4"))
|
7
|
-
fake("https://cl.ly/2C0E1V451J0C", response("cloudapp-jpg"))
|
8
|
-
fake("https://cl.ly/1x1f2g253l03", response("cloudapp-others"))
|
9
|
-
end
|
10
|
-
|
11
|
-
it "supports gif" do
|
12
|
-
expect(Onebox.preview('https://cl.ly/0m2a2u2k440O').to_s).to match(/<img/)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "supports mp4" do
|
16
|
-
expect(Onebox.preview('https://cl.ly/0T0c2J3S373X').to_s).to match(/<video/)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "supports jpg" do
|
20
|
-
expect(Onebox.preview('https://cl.ly/2C0E1V451J0C').to_s).to match(/<img/)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "links to other formats" do
|
24
|
-
expect(Onebox.preview('https://cl.ly/1x1f2g253l03').to_s).to match(/<a/)
|
25
|
-
end
|
26
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::DoubanOnebox do
|
4
|
-
before(:all) do
|
5
|
-
@link = "http://movie.douban.com/review/1503949/"
|
6
|
-
end
|
7
|
-
include_context "engines"
|
8
|
-
it_behaves_like "an engine"
|
9
|
-
|
10
|
-
before do
|
11
|
-
fake(link, response("douban.response"))
|
12
|
-
end
|
13
|
-
|
14
|
-
it "has douban title" do
|
15
|
-
expect(html).to include("那个荡气回肠的长镜头 (巴黎最后的探戈 影评)")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "has douban image" do
|
19
|
-
expect(html).to include("http://img3.douban.com/mpic/s2557510.jpg")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "has the douban description" do
|
23
|
-
expect(html).to include("<p>那个荡气回肠的长镜头")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "has the URL to the resource" do
|
27
|
-
expect(html).to include(link)
|
28
|
-
end
|
29
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::GfycatOnebox do
|
4
|
-
let(:link) { "https://gfycat.com/AmusingPoshCleanerwrasse" }
|
5
|
-
let(:api_link) { "https://gfycat.com/cajax/get/AmusingPoshCleanerwrasse" }
|
6
|
-
let(:html) { described_class.new(link).to_html }
|
7
|
-
let(:placeholder_html) { described_class.new(link).placeholder_html }
|
8
|
-
|
9
|
-
before do
|
10
|
-
fake(api_link, response("gfycat"))
|
11
|
-
end
|
12
|
-
|
13
|
-
it "has the title" do
|
14
|
-
expect(html).to include("AmusingPoshCleanerwrasse")
|
15
|
-
expect(placeholder_html).to include("AmusingPoshCleanerwrasse")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "has the link" do
|
19
|
-
expect(html).to include(link)
|
20
|
-
expect(placeholder_html).to include(link)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "has the poster" do
|
24
|
-
expect(html).to include("https://thumbs.gfycat.com/AmusingPoshCleanerwrasse-poster.jpg")
|
25
|
-
end
|
26
|
-
|
27
|
-
it "has the webm video" do
|
28
|
-
expect(html).to include("https://fat.gfycat.com/AmusingPoshCleanerwrasse.webm")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "has the mp4 video" do
|
32
|
-
expect(html).to include("https://giant.gfycat.com/AmusingPoshCleanerwrasse.mp4")
|
33
|
-
end
|
34
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::GithubBlobOnebox do
|
4
|
-
before(:all) do
|
5
|
-
@link = "https://github.com/discourse/discourse/blob/master/lib/oneboxer/github_blob_onebox.rb"
|
6
|
-
fake("https://raw.github.com/discourse/discourse/master/lib/oneboxer/github_blob_onebox.rb", response(described_class.onebox_name))
|
7
|
-
end
|
8
|
-
|
9
|
-
include_context "engines"
|
10
|
-
it_behaves_like "an engine"
|
11
|
-
|
12
|
-
describe "#to_html" do
|
13
|
-
it "includes file name" do
|
14
|
-
expect(html).to include("github_blob_onebox.rb")
|
15
|
-
end
|
16
|
-
|
17
|
-
it "includes blob contents" do
|
18
|
-
expect(html).to include("module Oneboxer")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::GithubCommitOnebox do
|
4
|
-
|
5
|
-
describe "regular commit url" do
|
6
|
-
before(:all) do
|
7
|
-
@link = "https://github.com/discourse/discourse/commit/803d023e2307309f8b776ab3b8b7e38ba91c0919"
|
8
|
-
@uri = "https://api.github.com/repos/discourse/discourse/commits/803d023e2307309f8b776ab3b8b7e38ba91c0919"
|
9
|
-
end
|
10
|
-
|
11
|
-
include_context "engines"
|
12
|
-
it_behaves_like "an engine"
|
13
|
-
|
14
|
-
describe "#to_html" do
|
15
|
-
it "includes owner" do
|
16
|
-
expect(html).to include("discourse")
|
17
|
-
end
|
18
|
-
|
19
|
-
it "includes repository name" do
|
20
|
-
expect(html).to include("discourse")
|
21
|
-
end
|
22
|
-
|
23
|
-
it "includes commit sha" do
|
24
|
-
expect(html).to include("803d023e2307309f8b776ab3b8b7e38ba91c0919")
|
25
|
-
end
|
26
|
-
|
27
|
-
it "includes commit author gravatar" do
|
28
|
-
expect(html).to include("2F7d3010c11d08cf990b7614d2c2ca9098.png")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "includes commit message" do
|
32
|
-
expect(html).to include("Fixed GitHub auth")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "includes commit author" do
|
36
|
-
expect(html).to include("SamSaffron")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "includes commit time and date" do
|
40
|
-
expect(html).to include("02:03AM - 02 Aug 13")
|
41
|
-
end
|
42
|
-
|
43
|
-
it "includes number of files changed" do
|
44
|
-
expect(html).to include("1 file")
|
45
|
-
end
|
46
|
-
|
47
|
-
it "includes number of additions" do
|
48
|
-
expect(html).to include("18 additions")
|
49
|
-
end
|
50
|
-
|
51
|
-
it "includes number of deletions" do
|
52
|
-
expect(html).to include("2 deletions")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "PR with commit URL" do
|
58
|
-
before(:all) do
|
59
|
-
@link = "https://github.com/discourse/discourse/pull/4662/commits/803d023e2307309f8b776ab3b8b7e38ba91c0919"
|
60
|
-
@uri = "https://api.github.com/repos/discourse/discourse/commits/803d023e2307309f8b776ab3b8b7e38ba91c0919"
|
61
|
-
end
|
62
|
-
|
63
|
-
include_context "engines"
|
64
|
-
it_behaves_like "an engine"
|
65
|
-
|
66
|
-
describe "#to_html" do
|
67
|
-
it "includes owner" do
|
68
|
-
expect(html).to include("discourse")
|
69
|
-
end
|
70
|
-
|
71
|
-
it "includes repository name" do
|
72
|
-
expect(html).to include("discourse")
|
73
|
-
end
|
74
|
-
|
75
|
-
it "includes commit sha" do
|
76
|
-
expect(html).to include("803d023e2307309f8b776ab3b8b7e38ba91c0919")
|
77
|
-
end
|
78
|
-
|
79
|
-
it "includes commit author gravatar" do
|
80
|
-
expect(html).to include("2F7d3010c11d08cf990b7614d2c2ca9098.png")
|
81
|
-
end
|
82
|
-
|
83
|
-
it "includes commit message" do
|
84
|
-
expect(html).to include("Fixed GitHub auth")
|
85
|
-
end
|
86
|
-
|
87
|
-
it "includes commit author" do
|
88
|
-
expect(html).to include("SamSaffron")
|
89
|
-
end
|
90
|
-
|
91
|
-
it "includes commit time and date" do
|
92
|
-
expect(html).to include("02:03AM - 02 Aug 13")
|
93
|
-
end
|
94
|
-
|
95
|
-
it "includes number of files changed" do
|
96
|
-
expect(html).to include("1 file")
|
97
|
-
end
|
98
|
-
|
99
|
-
it "includes number of additions" do
|
100
|
-
expect(html).to include("18 additions")
|
101
|
-
end
|
102
|
-
|
103
|
-
it "includes number of deletions" do
|
104
|
-
expect(html).to include("2 deletions")
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::GithubGistOnebox do
|
4
|
-
before(:all) do
|
5
|
-
@link = "https://gist.github.com/karreiro/208fdd59fc4b4c39283b"
|
6
|
-
fake("https://api.github.com/gists/208fdd59fc4b4c39283b", response(described_class.onebox_name))
|
7
|
-
end
|
8
|
-
|
9
|
-
include_context "engines"
|
10
|
-
it_behaves_like "an engine"
|
11
|
-
|
12
|
-
describe "#data" do
|
13
|
-
let(:gist_files) { data[:gist_files] }
|
14
|
-
|
15
|
-
it 'includes contents with 10 lines at most' do
|
16
|
-
gist_files.each do |gist_file|
|
17
|
-
truncated_lines = gist_file.content.split("\n").size
|
18
|
-
expect(truncated_lines).to be < 10
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "#to_html" do
|
24
|
-
describe 'when Gist API responds correctly' do
|
25
|
-
it "includes the link to original page" do
|
26
|
-
expect(html).to include("https://gist.github.com/karreiro/208fdd59fc4b4c39283b")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "includes three files" do
|
30
|
-
expect(html).to include("0.rb")
|
31
|
-
expect(html).to include("1.js")
|
32
|
-
expect(html).to include("2.md")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "does not include truncated files" do
|
36
|
-
expect(html).not_to include("3.java")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "includes gist contents" do
|
40
|
-
expect(html).to include("3.times { puts "Gist API test." }")
|
41
|
-
expect(html).to include("console.log("Hey! ;)")")
|
42
|
-
expect(html).to include("#### Hey, this is a test!")
|
43
|
-
end
|
44
|
-
|
45
|
-
it "does not include gist contents from truncated files" do
|
46
|
-
expect(html).not_to include("System.out.println("Wow! This is a test!");")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe 'when the rate limit has been reached' do
|
51
|
-
before(:all) do
|
52
|
-
FakeWeb.register_uri(:get, "https://api.github.com/gists/208fdd59fc4b4c39283b", status: 403)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "includes the link to original page" do
|
56
|
-
expect(html).to include("https://gist.github.com/karreiro/208fdd59fc4b4c39283b")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "does not include any file" do
|
60
|
-
expect(html).not_to include("0.rb")
|
61
|
-
expect(html).not_to include("1.js")
|
62
|
-
expect(html).not_to include("2.md")
|
63
|
-
expect(html).not_to include("3.java")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Onebox::Engine::GithubPullRequestOnebox do
|
4
|
-
before(:all) do
|
5
|
-
@link = "https://github.com/discourse/discourse/pull/1253/"
|
6
|
-
@uri = "https://api.github.com/repos/discourse/discourse/pulls/1253"
|
7
|
-
fake(@uri, response(described_class.onebox_name))
|
8
|
-
end
|
9
|
-
|
10
|
-
include_context "engines"
|
11
|
-
it_behaves_like "an engine"
|
12
|
-
|
13
|
-
describe "#to_html" do
|
14
|
-
it "includes pull request author" do
|
15
|
-
expect(html).to include("jamesaanderson")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "includes repository name" do
|
19
|
-
expect(html).to include("discourse")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "includes commit author gravatar" do
|
23
|
-
expect(html).to include("b3e9977094ce189bbb493cf7f9adea21")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "includes commit time and date" do
|
27
|
-
expect(html).to include("02:05AM - 26 Jul 13")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "includes number of commits" do
|
31
|
-
expect(html).to include("1")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "includes number of files changed" do
|
35
|
-
expect(html).to include("4")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "includes number of additions" do
|
39
|
-
expect(html).to include("19")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "includes number of deletions" do
|
43
|
-
expect(html).to include("1")
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|