onebox 1.5.5 → 1.5.6

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.
@@ -1,23 +1,67 @@
1
- # Broken for now
2
- #
3
- # require "spec_helper"
4
- #
5
- # describe Onebox::Engine::GithubGistOnebox do
6
- # before(:all) do
7
- # @link = "https://gist.github.com/anikalindtner/153044e9bea3331cc103"
8
- # @uri = "https://api.github.com/gists/153044e9bea3331cc103"
9
- # end
10
- #
11
- # include_context "engines"
12
- # it_behaves_like "an engine"
13
- #
14
- # describe "#to_html" do
15
- # it "includes sha" do
16
- # expect(html).to include("153044e9bea3331cc103")
17
- # end
18
- #
19
- # it "includes script" do
20
- # expect(html).to include("script")
21
- # end
22
- # end
23
- # end
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 &quot;Gist API test.&quot; }")
41
+ expect(html).to include("console.log(&quot;Hey! ;)&quot;)")
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(&quot;Wow! This is a test!&quot;);")
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
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+
3
+ describe Onebox::Engine::YoukuOnebox do
4
+ before do
5
+ FakeWeb.register_uri(:get, 'http://v.youku.com/v_show/id_XNjM3MzAxNzc2.html', body: response('youku'), content_type: 'text/html')
6
+ FakeWeb.register_uri(:get, 'http://v.youku.com/player/getPlayList/VideoIDS/XNjM3MzAxNzc2', body: response('youku-meta'), content_type: 'text/html')
7
+ end
8
+
9
+ it 'returns an image as the placeholder' do
10
+ Onebox.preview('http://v.youku.com/v_show/id_XNjM3MzAxNzc2.html')
11
+ .placeholder_html.should match(/<img/)
12
+ end
13
+ end
@@ -29,7 +29,7 @@ describe Onebox do
29
29
  end
30
30
 
31
31
  describe "templates" do
32
- let(:ignored) { ["templates/_layout.mustache", "templates/githubgist.mustache"] }
32
+ let(:ignored) { ["templates/_layout.mustache"] }
33
33
  let(:templates) { Dir["templates/*.mustache"] - ignored }
34
34
 
35
35
  def expect_templates_to_not_match(text)
@@ -0,0 +1,12 @@
1
+ <h4><a href="{{link}}" target="_blank">{{link}}</a></h4>
2
+ {{#gist_files}}
3
+ <h5>{{filename}}</h5>
4
+ <pre><code class='{{language}}'>{{content}}</code></pre>
5
+ {{#truncated?}}This file has been truncated. <a href="{{link}}" target="_blank">show original</a>{{/truncated?}}
6
+ {{/gist_files}}
7
+
8
+ <p>
9
+ {{#truncated_files?}}
10
+ There are more than three files. <a href="{{link}}" target="_blank">show original</a>
11
+ {{/truncated_files?}}
12
+ </p>
@@ -1,4 +1,5 @@
1
- <h3>{{developer}}</h3>
1
+ <h3>{{title}}</h3>
2
+ <h4>{{developer}}</h4>
2
3
  <img src="{{image}}" class="thumbnail"/>
3
4
  <p>{{description}}</p>
4
5
  <em>{{price}}</em>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-11-14 00:00:00.000000000 Z
13
+ date: 2014-12-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -263,7 +263,9 @@ files:
263
263
  - lib/onebox/engine/video_onebox.rb
264
264
  - lib/onebox/engine/whitelisted_generic_onebox.rb
265
265
  - lib/onebox/engine/wikipedia_onebox.rb
266
+ - lib/onebox/engine/youku_onebox.rb
266
267
  - lib/onebox/engine/youtube_onebox.rb
268
+ - lib/onebox/file_type_finder.rb
267
269
  - lib/onebox/helpers.rb
268
270
  - lib/onebox/layout.rb
269
271
  - lib/onebox/layout_support.rb
@@ -277,6 +279,7 @@ files:
277
279
  - spec/fixtures/douban.response
278
280
  - spec/fixtures/githubblob.response
279
281
  - spec/fixtures/githubcommit.response
282
+ - spec/fixtures/githubgist.response
280
283
  - spec/fixtures/githubpullrequest.response
281
284
  - spec/fixtures/googleplayapp.response
282
285
  - spec/fixtures/image.response
@@ -287,6 +290,8 @@ files:
287
290
  - spec/fixtures/video.response
288
291
  - spec/fixtures/wikipedia.response
289
292
  - spec/fixtures/wikipediaredirected.response
293
+ - spec/fixtures/youku-meta.response
294
+ - spec/fixtures/youku.response
290
295
  - spec/fixtures/youtube-channel.response
291
296
  - spec/fixtures/youtube.response
292
297
  - spec/lib/onebox/engine/amazon_onebox_spec.rb
@@ -307,6 +312,7 @@ files:
307
312
  - spec/lib/onebox/engine/video_onebox_spec.rb
308
313
  - spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
309
314
  - spec/lib/onebox/engine/wikipedia_onebox_spec.rb
315
+ - spec/lib/onebox/engine/youku_onebox_spec.rb
310
316
  - spec/lib/onebox/engine/youtube_onebox_spec.rb
311
317
  - spec/lib/onebox/engine_spec.rb
312
318
  - spec/lib/onebox/layout_spec.rb
@@ -320,6 +326,7 @@ files:
320
326
  - templates/douban.mustache
321
327
  - templates/githubblob.mustache
322
328
  - templates/githubcommit.mustache
329
+ - templates/githubgist.mustache
323
330
  - templates/githubissue.mustache
324
331
  - templates/githubpullrequest.mustache
325
332
  - templates/googleplayapp.mustache
@@ -358,6 +365,7 @@ test_files:
358
365
  - spec/fixtures/douban.response
359
366
  - spec/fixtures/githubblob.response
360
367
  - spec/fixtures/githubcommit.response
368
+ - spec/fixtures/githubgist.response
361
369
  - spec/fixtures/githubpullrequest.response
362
370
  - spec/fixtures/googleplayapp.response
363
371
  - spec/fixtures/image.response
@@ -368,6 +376,8 @@ test_files:
368
376
  - spec/fixtures/video.response
369
377
  - spec/fixtures/wikipedia.response
370
378
  - spec/fixtures/wikipediaredirected.response
379
+ - spec/fixtures/youku-meta.response
380
+ - spec/fixtures/youku.response
371
381
  - spec/fixtures/youtube-channel.response
372
382
  - spec/fixtures/youtube.response
373
383
  - spec/lib/onebox/engine/amazon_onebox_spec.rb
@@ -388,6 +398,7 @@ test_files:
388
398
  - spec/lib/onebox/engine/video_onebox_spec.rb
389
399
  - spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
390
400
  - spec/lib/onebox/engine/wikipedia_onebox_spec.rb
401
+ - spec/lib/onebox/engine/youku_onebox_spec.rb
391
402
  - spec/lib/onebox/engine/youtube_onebox_spec.rb
392
403
  - spec/lib/onebox/engine_spec.rb
393
404
  - spec/lib/onebox/layout_spec.rb