onebox 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +4 -0
  3. data/.travis.yml +4 -0
  4. data/README.md +154 -113
  5. data/lib/onebox.rb +6 -3
  6. data/lib/onebox/engine.rb +28 -26
  7. data/lib/onebox/engine/amazon_onebox.rb +4 -2
  8. data/lib/onebox/engine/bliptv_onebox.rb +4 -2
  9. data/lib/onebox/engine/clikthrough_onebox.rb +4 -2
  10. data/lib/onebox/engine/college_humor_onebox.rb +3 -2
  11. data/lib/onebox/engine/dailymotion_onebox.rb +4 -2
  12. data/lib/onebox/engine/dotsub_onebox.rb +4 -2
  13. data/lib/onebox/engine/example_onebox.rb +4 -5
  14. data/lib/onebox/engine/flickr_onebox.rb +3 -2
  15. data/lib/onebox/engine/funny_or_die_onebox.rb +4 -2
  16. data/lib/onebox/engine/github_blob_onebox.rb +28 -0
  17. data/lib/onebox/engine/github_commit_onebox.rb +43 -0
  18. data/lib/onebox/engine/github_gist_onebox.rb +33 -0
  19. data/lib/onebox/engine/github_pullrequest_onebox.rb +43 -0
  20. data/lib/onebox/engine/html.rb +1 -1
  21. data/lib/onebox/engine/hulu_onebox.rb +5 -2
  22. data/lib/onebox/engine/imgur_image_onebox.rb +26 -0
  23. data/lib/onebox/engine/itunes_onebox.rb +28 -0
  24. data/lib/onebox/engine/json.rb +11 -0
  25. data/lib/onebox/engine/kinomap_onebox.rb +27 -0
  26. data/lib/onebox/engine/nfb_onebox.rb +5 -2
  27. data/lib/onebox/engine/open_graph.rb +1 -1
  28. data/lib/onebox/engine/qik_onebox.rb +4 -2
  29. data/lib/onebox/engine/revision3_onebox.rb +3 -2
  30. data/lib/onebox/engine/slideshare_onebox.rb +4 -2
  31. data/lib/onebox/engine/sound_cloud_onebox.rb +4 -2
  32. data/lib/onebox/engine/spotify_onebox.rb +27 -0
  33. data/lib/onebox/engine/stack_exchange_onebox.rb +4 -2
  34. data/lib/onebox/engine/ted_onebox.rb +5 -2
  35. data/lib/onebox/engine/twitter_onebox.rb +31 -0
  36. data/lib/onebox/engine/viddler_onebox.rb +5 -3
  37. data/lib/onebox/engine/vimeo_onebox.rb +3 -2
  38. data/lib/onebox/engine/wikipedia_onebox.rb +4 -2
  39. data/lib/onebox/engine/yfrog_onebox.rb +5 -2
  40. data/lib/onebox/version.rb +1 -1
  41. data/lib/onebox/view.rb +21 -0
  42. data/onebox.gemspec +1 -1
  43. data/spec/fixtures/githubblob.response +922 -0
  44. data/spec/fixtures/githubcommit.response +87 -0
  45. data/spec/fixtures/githubgist.response +468 -0
  46. data/spec/fixtures/githubpullrequest.response +216 -0
  47. data/spec/fixtures/imguralbum.response +941 -0
  48. data/spec/fixtures/{imgur.response → imgurimage.response} +870 -890
  49. data/spec/fixtures/itunes.response +402 -0
  50. data/spec/fixtures/{rottentomatoes_fresh.response → rottentomatoesfresh.response} +0 -0
  51. data/spec/fixtures/{rottentomatoes_incomplete.response → rottentomatoesincomplete.response} +0 -0
  52. data/spec/fixtures/{rottentomatoes_rotten.response → rottentomatoesrotten.response} +0 -0
  53. data/spec/fixtures/spotify.response +250 -0
  54. data/spec/fixtures/{wikipedia_redirected.response → wikipediaredirected.response} +0 -0
  55. data/spec/lib/onebox/engine/{amazon_spec.rb → amazon_onebox_spec.rb} +7 -4
  56. data/spec/lib/onebox/engine/{bliptv_spec.rb → bliptv_onebox_spec.rb} +7 -4
  57. data/spec/lib/onebox/engine/{clikthrough_spec.rb → clikthrough_onebox_spec.rb} +7 -4
  58. data/spec/lib/onebox/engine/{college_humor_spec.rb → college_humor_onebox_spec.rb} +7 -4
  59. data/spec/lib/onebox/engine/{dailymotion_spec.rb → dailymotion_onebox_spec.rb} +7 -4
  60. data/spec/lib/onebox/engine/{dotsub_spec.rb → dotsub_onebox_spec.rb} +7 -4
  61. data/spec/lib/onebox/engine/example_onebox_spec.rb +21 -0
  62. data/spec/lib/onebox/engine/{flickr_spec.rb → flickr_onebox_spec.rb} +7 -4
  63. data/spec/lib/onebox/engine/{funny_or_die_spec.rb → funny_or_die_onebox_spec.rb} +7 -4
  64. data/spec/lib/onebox/engine/github_blob_onebox_spec.rb +30 -0
  65. data/spec/lib/onebox/engine/github_commit_onebox_spec.rb +61 -0
  66. data/spec/lib/onebox/engine/github_gist_onebox_spec.rb +29 -0
  67. data/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb +58 -0
  68. data/spec/lib/onebox/engine/html_spec.rb +27 -0
  69. data/spec/lib/onebox/engine/{hulu_spec.rb → hulu_onebox_spec.rb} +7 -4
  70. data/spec/lib/onebox/engine/imgur_image_onebox_spec.rb +29 -0
  71. data/spec/lib/onebox/engine/itunes_onebox_spec.rb +29 -0
  72. data/spec/lib/onebox/engine/json_spec.rb +27 -0
  73. data/spec/lib/onebox/engine/kinomap_onebox_spec.rb +37 -0
  74. data/spec/lib/onebox/engine/{nfb_spec.rb → nfb_onebox_spec.rb} +7 -4
  75. data/spec/lib/onebox/engine/open_graph_spec.rb +27 -0
  76. data/spec/lib/onebox/engine/{qik_spec.rb → qik_onebox_spec.rb} +7 -4
  77. data/spec/lib/onebox/engine/{revision3_spec.rb → revision3_onebox_spec.rb} +7 -4
  78. data/spec/lib/onebox/engine/{slideshare_spec.rb → slideshare_onebox_spec.rb} +7 -4
  79. data/spec/lib/onebox/engine/{sound_cloud_spec.rb → sound_cloud_onebox_spec.rb} +7 -4
  80. data/spec/lib/onebox/engine/spotify_onebox_spec.rb +36 -0
  81. data/spec/lib/onebox/engine/{stack_exchange_spec.rb → stack_exchange_onebox_spec.rb} +7 -4
  82. data/spec/lib/onebox/engine/{ted_spec.rb → ted_onebox_spec.rb} +7 -4
  83. data/spec/lib/onebox/engine/twitter_onebox_spec.rb +47 -0
  84. data/spec/lib/onebox/engine/{viddler_spec.rb → viddler_onebox_spec.rb} +7 -4
  85. data/spec/lib/onebox/engine/{vimeo_spec.rb → vimeo_onebox_spec.rb} +7 -4
  86. data/spec/lib/onebox/engine/{wikipedia_spec.rb → wikipedia_onebox_spec.rb} +7 -4
  87. data/spec/lib/onebox/engine/{yfrog_spec.rb → yfrog_onebox_spec.rb} +7 -4
  88. data/spec/lib/onebox/engine_spec.rb +38 -27
  89. data/spec/lib/onebox/preview_spec.rb +3 -1
  90. data/spec/lib/onebox/view_spec.rb +16 -0
  91. data/spec/lib/onebox_spec.rb +1 -1
  92. data/spec/spec_helper.rb +8 -3
  93. data/spec/support/html_spec_helper.rb +1 -1
  94. data/templates/_layout.mustache +4 -0
  95. data/templates/amazon.mustache +5 -0
  96. data/templates/bliptv.mustache +5 -0
  97. data/templates/clikthrough.mustache +4 -0
  98. data/templates/collegehumor.mustache +5 -0
  99. data/templates/dailymotion.mustache +5 -0
  100. data/templates/dotsub.mustache +5 -0
  101. data/templates/example.mustache +2 -0
  102. data/templates/flickr.mustache +4 -0
  103. data/templates/funnyordie.mustache +6 -0
  104. data/templates/githubblob.mustache +5 -0
  105. data/templates/githubcommit.mustache +11 -0
  106. data/templates/githubgist.mustache +3 -0
  107. data/templates/githubpullrequest.mustache +14 -0
  108. data/templates/hulu.mustache +6 -0
  109. data/templates/imgurimage.mustache +3 -0
  110. data/templates/itunes.mustache +4 -0
  111. data/templates/kinomap.mustache +5 -0
  112. data/templates/nfb.mustache +5 -0
  113. data/templates/qik.mustache +4 -0
  114. data/templates/revision3.mustache +5 -0
  115. data/templates/slideshare.mustache +4 -0
  116. data/templates/soundcloud.mustache +5 -0
  117. data/templates/spotify.mustache +4 -0
  118. data/templates/stackexchange.mustache +3 -0
  119. data/templates/ted.mustache +5 -0
  120. data/templates/twitter.mustache +7 -0
  121. data/templates/viddler.mustache +5 -0
  122. data/templates/vimeo.mustache +5 -0
  123. data/templates/wikipedia.mustache +4 -0
  124. data/templates/yfrog.mustache +4 -0
  125. metadata +139 -90
  126. data/spec/fixtures/apple.response +0 -391
  127. data/spec/fixtures/clickthrough.response +0 -1472
  128. data/spec/fixtures/gist.response +0 -282
  129. data/spec/fixtures/github_blob.response +0 -706
  130. data/spec/fixtures/github_commit.response +0 -881
  131. data/spec/fixtures/github_pullrequest.response +0 -1619
  132. data/spec/lib/onebox/engine/example_spec.rb +0 -18
  133. data/templates/amazon.handlebars +0 -9
  134. data/templates/bliptv.handlebars +0 -10
  135. data/templates/clickthrough.handlebars +0 -8
  136. data/templates/clikthrough.handlebars +0 -8
  137. data/templates/collegehumor.handlebars +0 -9
  138. data/templates/dailymotion.handlebars +0 -9
  139. data/templates/dotsub.handlebars +0 -9
  140. data/templates/flickr.handlebars +0 -8
  141. data/templates/funnyordie.handlebars +0 -9
  142. data/templates/hulu.handlebars +0 -9
  143. data/templates/nfb.handlebars +0 -8
  144. data/templates/qik.handlebars +0 -7
  145. data/templates/revision3.handlebars +0 -9
  146. data/templates/slideshare.handlebars +0 -8
  147. data/templates/soundcloud.handlebars +0 -9
  148. data/templates/stackexchange.handlebars +0 -7
  149. data/templates/ted.handlebars +0 -8
  150. data/templates/viddler.handlebars +0 -9
  151. data/templates/vimeo.handlebars +0 -9
  152. data/templates/wikipedia.handlebars +0 -8
  153. data/templates/yfrog.handlebars +0 -8
@@ -1,12 +1,15 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Onebox::Engine::AmazonOnebox do
4
- let(:link) { "http://amazon.com" }
5
- before do
6
- fake(link, response("amazon.response"))
4
+ before(:all) do
5
+ @link = "http://www.amazon.com/Knit-Noro-Accessories-Colorful-Little/dp/193609620X"
6
+ fake(@link, response(described_class.template_name))
7
7
  end
8
+ before(:each) { Onebox.defaults.cache.clear }
8
9
 
9
- it_behaves_like "engines"
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::BliptvOnebox do
4
- let(:link) { "http://blip.tv" }
5
- before do
6
- fake(link, response("bliptv.response"))
4
+ before(:all) do
5
+ @link = "http://blip.tv"
6
+ fake(@link, response(described_class.template_name))
7
7
  end
8
+ before(:each) { Onebox.defaults.cache.clear }
8
9
 
9
- it_behaves_like "engines"
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::ClikThroughOnebox do
4
- let(:link) { "http://www.clickthough.com"}
5
- before do
6
- fake(link, response("clikthrough.response"))
4
+ before(:all) do
5
+ @link = "http://www.clikthrough.com/theater/video/49/en-US"
6
+ fake(@link, response(described_class.template_name))
7
7
  end
8
+ before(:each) { Onebox.defaults.cache.clear }
8
9
 
9
- it_behaves_like "engines"
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::CollegeHumorOnebox do
4
- let(:link) { "http://collegehumor.com" }
5
- before do
6
- fake(link, response("collegehumor.response"))
4
+ before(:all) do
5
+ @link = "http://collegehumor.com"
6
+ fake(@link, response(described_class.template_name))
7
7
  end
8
+ before(:each) { Onebox.defaults.cache.clear }
8
9
 
9
- it_behaves_like "engines"
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::DailymotionOnebox do
4
- let(:link) { "http://dailymotion.com" }
5
- before do
6
- fake(link, response("dailymotion.response"))
4
+ before(:all) do
5
+ @link = "http://dailymotion.com"
6
+ fake(@link, response(described_class.template_name))
7
7
  end
8
+ before(:each) { Onebox.defaults.cache.clear }
8
9
 
9
- it_behaves_like "engines"
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::DotsubOnebox do
4
- let(:link) { "http://dotsub.com/view/665bd0d5-a9f4-4a07-9d9e-b31ba926ca78" }
5
- before do
6
- fake(link, response("dotsub.response"))
4
+ before(:all) do
5
+ @link = "http://dotsub.com/view/665bd0d5-a9f4-4a07-9d9e-b31ba926ca78"
6
+ fake(@link, response(described_class.template_name))
7
7
  end
8
+ before(:each) { Onebox.defaults.cache.clear }
8
9
 
9
- it_behaves_like "engines"
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,21 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::ExampleOnebox do
4
+ before(:all) do
5
+ @link = "http://example.com"
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 template if given valid data" do
18
+ expect(html).to include("Example Domain 1")
19
+ end
20
+ end
21
+ end
@@ -1,12 +1,15 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Onebox::Engine::FlickrOnebox do
4
- let(:link) { "http://flickr.com" }
5
- before do
6
- fake(link, response("flickr.response"))
4
+ before(:all) do
5
+ @link = "http://flickr.com"
6
+ fake(@link, response(described_class.template_name))
7
7
  end
8
+ before(:each) { Onebox.defaults.cache.clear }
8
9
 
9
- it_behaves_like "engines"
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::FunnyOrDieOnebox do
4
- let(:link) { "http://funnyordie.com" }
5
- before do
6
- fake(link, response("funnyordie.response"))
4
+ before(:all) do
5
+ @link = "http://funnyordie.com"
6
+ fake(@link, response(described_class.template_name))
7
7
  end
8
+ before(:each) { Onebox.defaults.cache.clear }
8
9
 
9
- it_behaves_like "engines"
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,30 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::GithubBlobOnebox do
4
+ let(:link) { "https://github.com/discourse/discourse/blob/master/lib/oneboxer/github_blob_onebox.rb" }
5
+ before do
6
+ fake(link, response("githubblob"))
7
+ end
8
+
9
+ it_behaves_like "an engine"
10
+
11
+ describe "#to_html" do
12
+ let(:html) { described_class.new(link).to_html }
13
+
14
+ it "has file name" do
15
+ expect(html).to include("github_blob_onebox.rb")
16
+ end
17
+
18
+ it "has number of lines" do
19
+ expect(html).to include("50")
20
+ end
21
+
22
+ it "has blob contents" do
23
+ expect(html).to include("module Oneboxer")
24
+ end
25
+
26
+ it "has URL" do
27
+ expect(html).to include(link)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,61 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::GithubCommitOnebox do
4
+ before(:all) do
5
+ @link = "https://github.com/discourse/discourse/commit/803d023e2307309f8b776ab3b8b7e38ba91c0919"
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 repo owner" do
18
+ expect(html).to include("discourse")
19
+ end
20
+
21
+ it "has repo name" do
22
+ expect(html).to include("discourse")
23
+ end
24
+
25
+ it "has commit sha" do
26
+ expect(html).to include("803d023e2307309f8b776ab3b8b7e38ba91c0919")
27
+ end
28
+
29
+ it "has commit author gravatar" do
30
+ expect(html).to include("2F7d3010c11d08cf990b7614d2c2ca9098.png")
31
+ end
32
+
33
+ it "has commit message" do
34
+ expect(html).to include("Fixed GitHub auth")
35
+ end
36
+
37
+ it "has commit author" do
38
+ expect(html).to include("SamSaffron")
39
+ end
40
+
41
+ it "has commit time and date" do
42
+ expect(html).to include("2013-08-02T02:16:44Z")
43
+ end
44
+
45
+ it "has number of files changed" do
46
+ expect(html).to include("1 changed file")
47
+ end
48
+
49
+ it "has number of additions" do
50
+ expect(html).to include("18 additions")
51
+ end
52
+
53
+ it "has number of deletions" do
54
+ expect(html).to include("2 deletions")
55
+ end
56
+
57
+ it "has URL" do
58
+ expect(html).to include(link)
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::GithubGistOnebox do
4
+ before(:all) do
5
+ @link = "https://gist.github.com/anikalindtner/153044e9bea3331cc103"
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 raw file contents" do
18
+ expect(html).to include("# Create a new blog post on GitHub")
19
+ end
20
+
21
+ it "has author" do
22
+ expect(html).to include("anikalindtner")
23
+ end
24
+
25
+ it "has URL" do
26
+ expect(html).to include(link)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,58 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::GithubPullRequestOnebox do
4
+ let(:link) { "https://github.com/discourse/discourse/pull/1253/" }
5
+ before do
6
+ fake(link, response("githubpullrequest"))
7
+ end
8
+
9
+ it_behaves_like "an engine"
10
+
11
+ describe "#to_html" do
12
+ let(:html) { described_class.new(link).to_html }
13
+
14
+ it "has pull request author" do
15
+ expect(html).to include("jamesaanderson")
16
+ end
17
+
18
+ it "has pull request title" do
19
+ expect(html).to include("Add audio onebox")
20
+ end
21
+
22
+ it "has repo name" do
23
+ expect(html).to include("discourse")
24
+ end
25
+
26
+ it "has commit author gravatar" do
27
+ expect(html).to include("b3e9977094ce189bbb493cf7f9adea21")
28
+ end
29
+
30
+ it "has commit description" do
31
+ expect(html).to include("8168")
32
+ end
33
+
34
+ it "has commit time and date" do
35
+ expect(html).to include("2013-07-26T02:05:53Z")
36
+ end
37
+
38
+ it "has number of commits" do
39
+ expect(html).to include("1")
40
+ end
41
+
42
+ it "has number of files changed" do
43
+ expect(html).to include("4")
44
+ end
45
+
46
+ it "has number of additions" do
47
+ expect(html).to include("19")
48
+ end
49
+
50
+ it "has number of deletions" do
51
+ expect(html).to include("1")
52
+ end
53
+
54
+ it "has URL" do
55
+ expect(html).to include(link)
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::HTML do
4
+ before(:all) do
5
+ @link = "http://example.com"
6
+ fake(@link, response("example"))
7
+ end
8
+ before(:each) { Onebox.defaults.cache.clear }
9
+
10
+ let(:link) { @link }
11
+
12
+ describe "#raw" do
13
+ class OneboxEngineHTML
14
+ include Onebox::Engine
15
+ include Onebox::Engine::HTML
16
+
17
+ def initialize(link)
18
+ @url = link
19
+ end
20
+ end
21
+
22
+ it "returns a Nokogiri object that has a css method" do
23
+ object = OneboxEngineHTML.new("http://example.com").send(:raw)
24
+ expect(object).to respond_to(:css)
25
+ end
26
+ end
27
+ end
@@ -1,12 +1,15 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Onebox::Engine::HuluOnebox do
4
- let(:link) { "http://hulu.com" }
5
- before do
6
- fake(link, response("hulu.response"))
4
+ before(:all) do
5
+ @link = "http://www.hulu.com/watch/515146"
6
+ fake(@link, response(described_class.template_name))
7
7
  end
8
+ before(:each) { Onebox.defaults.cache.clear }
8
9
 
9
- it_behaves_like "engines"
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,29 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::ImgurImageOnebox do
4
+ before(:all) do
5
+ @link = "http://imgur.com/gallery/twoDTCU"
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 the image title" do
18
+ expect(html).to include("My dog likes to hug me")
19
+ end
20
+
21
+ it "returns the image" do
22
+ expect(html).to include("twoDTCU.jpg")
23
+ end
24
+
25
+ it "returns URL" do
26
+ expect(html).to include(link)
27
+ end
28
+ end
29
+ end