onebox 1.5.17 → 1.5.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 451ff8d5ee7ce3d3c3fdeffca55cccba29cdb91c
4
- data.tar.gz: 83033812a9b67dd10048cfe72896c5b315e2d5da
3
+ metadata.gz: d1ad782f96ff776d0d2266234a1a35c728fda673
4
+ data.tar.gz: f6f790cb45621ec73844872684e855de29142484
5
5
  SHA512:
6
- metadata.gz: a76b282e64d1191b6e7ddd4dc2f8a2b8f30c6f10f409a12ee71d3e794005c6cba66f26d315aec092e05ceb6bc586af6afe2c08ea29ba14000ebb4afd330992c6
7
- data.tar.gz: 10faeefda12d96758903bbb6f11e1bfc2462a4f73e6be19466e1b6f3030d3eeb93ca2b0ceb9e7d74114fc0f04e25b5f272b24efc47125dce3b88027280f826a8
6
+ metadata.gz: f5fccca33ea465d18f16ccd6d277f96065a07c20c9d807efdd7e59e85f28c8846267cea1f8ea763f0c909f8395eb8ba01d5c2f2f22250c18587879762e520f83
7
+ data.tar.gz: e3b611db4ce5d131643102aa3642047a092ca0f16223329a367f02c4407c075fc9af1ab2949098fb7162c79c558a3e60d7c3455ce21675c62599602b9399d089
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require "rspec/core/rake_task"
3
3
  require "yard"
4
+ require 'bundler'
4
5
 
5
6
  begin
6
7
  Bundler.setup :default, :development
@@ -57,6 +57,14 @@ module Onebox
57
57
  html
58
58
  end
59
59
 
60
+ def video_title
61
+ yt_oembed_url = "http://www.youtube.com/oembed?format=json&url=http://www.youtube.com/watch?v=#{video_id.split('?')[0]}"
62
+ yt_oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(Onebox::Helpers.fetch_response(yt_oembed_url).body))
63
+ yt_oembed_data[:title]
64
+ rescue
65
+ return nil
66
+ end
67
+
60
68
  # Regex to parse strings like "1h3m2s". Also accepts bare numbers (which are seconds).
61
69
  TIMESTR_REGEX = /(\d+h)?(\d+m)?(\d+s?)?/
62
70
 
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.5.17"
2
+ VERSION = "1.5.18"
3
3
  end
data/onebox.gemspec CHANGED
@@ -4,39 +4,37 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'onebox/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "onebox"
7
+ spec.name = 'onebox'
8
8
  spec.version = Onebox::VERSION
9
- spec.authors = ["Joanna Zeta", "Vyki Englert", "Robin Ward"]
10
- spec.email = ["holla@jzeta.com", "vyki.englert@gmail.com", "robin.ward@gmail.com"]
9
+ spec.authors = ['Joanna Zeta', 'Vyki Englert', 'Robin Ward']
10
+ spec.email = ['holla@jzeta.com', 'vyki.englert@gmail.com', 'robin.ward@gmail.com']
11
11
  spec.description = %q{A gem for turning URLs into previews.}
12
12
  spec.summary = spec.description
13
- spec.homepage = "https://github.com/discourse/onebox"
14
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/discourse/onebox'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency "multi_json", "~> 1.7"
22
- spec.add_runtime_dependency "mustache", "~> 0.99"
23
- spec.add_runtime_dependency "nokogiri", "~> 1.6.1"
24
- spec.add_runtime_dependency "moneta", "~> 0.7"
21
+ spec.add_runtime_dependency 'multi_json', '~> 1.11'
22
+ spec.add_runtime_dependency 'mustache'
23
+ spec.add_runtime_dependency 'nokogiri', '~> 1.6.6'
24
+ spec.add_runtime_dependency 'moneta', '~> 0.8'
25
25
 
26
- spec.add_development_dependency "bundler", "~> 1.3"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 2.14"
29
- spec.add_development_dependency "yard", "~> 0.8"
30
- spec.add_development_dependency "fakeweb", "~> 1.3"
31
- spec.add_development_dependency "pry", "~> 0.9"
32
- spec.add_development_dependency "mocha", "~> 0.14"
33
- spec.add_development_dependency "rubocop", "~> 0.11"
34
- spec.add_development_dependency "twitter", "~> 4.8"
35
- spec.add_development_dependency "guard-rspec", "~> 4.2.8"
36
- spec.add_development_dependency "sinatra", "~> 1.4"
37
- spec.add_development_dependency "sinatra-contrib", "~> 1.4"
38
- spec.add_development_dependency "haml", "~> 4.0"
39
- # listen current is a bit broken
40
- # http://stackoverflow.com/questions/21319753/readline-seems-to-be-broken
41
- spec.add_development_dependency "listen", "= 2.6.0"
26
+ spec.add_development_dependency 'bundler', '~> 1.7'
27
+ spec.add_development_dependency 'rake', '~> 10.4'
28
+ spec.add_development_dependency 'rspec', '~> 3.2'
29
+ spec.add_development_dependency 'yard', '~> 0.8'
30
+ spec.add_development_dependency 'fakeweb', '~> 1.3'
31
+ spec.add_development_dependency 'pry', '~> 0.10'
32
+ spec.add_development_dependency 'mocha', '~> 1.1'
33
+ spec.add_development_dependency 'rubocop', '~> 0.30'
34
+ spec.add_development_dependency 'twitter', '~> 4.8'
35
+ spec.add_development_dependency 'guard-rspec', '~> 4.2.8'
36
+ spec.add_development_dependency 'sinatra', '~> 1.4'
37
+ spec.add_development_dependency 'sinatra-contrib', '~> 1.4'
38
+ spec.add_development_dependency 'haml', '~> 4.0'
39
+ spec.add_development_dependency 'listen', '~> 2.10.0'
42
40
  end
@@ -2,26 +2,26 @@ require "spec_helper"
2
2
 
3
3
  describe Onebox::Engine::AudioOnebox do
4
4
  it "supports ogg" do
5
- Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg').to_s.should match(/<audio/)
5
+ expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg').to_s).to match(/<audio/)
6
6
  end
7
7
 
8
8
  it "supports mp3" do
9
- Onebox.preview('http://kolber.github.io/audiojs/demos/mp3/juicy.mp3').to_s.should match(/<audio/)
9
+ expect(Onebox.preview('http://kolber.github.io/audiojs/demos/mp3/juicy.mp3').to_s).to match(/<audio/)
10
10
  end
11
11
 
12
12
  it "supports wav" do
13
- Onebox.preview('http://download.wavetlan.com/SVV/Media/HTTP/sample14.wav').to_s.should match(/<audio/)
13
+ expect(Onebox.preview('http://download.wavetlan.com/SVV/Media/HTTP/sample14.wav').to_s).to match(/<audio/)
14
14
  end
15
15
 
16
16
  it "supports URLs with query parameters" do
17
- Onebox.preview('https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg?foo=bar').to_s.should match(/<audio/)
17
+ expect(Onebox.preview('https://upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg?foo=bar').to_s).to match(/<audio/)
18
18
  end
19
19
 
20
20
  it "supports protocol relative URLs" do
21
- Onebox.preview('//upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg').to_s.should match(/<audio/)
21
+ expect(Onebox.preview('//upload.wikimedia.org/wikipedia/commons/c/c8/Example.ogg').to_s).to match(/<audio/)
22
22
  end
23
23
 
24
24
  it "includes a fallback direct link to the audio" do
25
- Onebox.preview('http://kolber.github.io/audiojs/demos/mp3/juicy.mp3').to_s.should match(/<a.*mp3/)
25
+ expect(Onebox.preview('http://kolber.github.io/audiojs/demos/mp3/juicy.mp3').to_s).to match(/<a.*mp3/)
26
26
  end
27
27
  end
@@ -48,10 +48,12 @@ describe Onebox::Engine::GoogleMapsOnebox do
48
48
  end
49
49
 
50
50
  # Prevent sleep from wasting our time when we test with strange redirects
51
- subject { described_class.send(:allocate).tap {|obj|
52
- obj.stub(:sleep)
53
- obj.send(:initialize, link)
54
- }}
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
55
57
 
56
58
  let(:data) { Onebox::Helpers.symbolize_keys(subject.send(:data)) }
57
59
  let(:link) {|example| URLS[example.metadata[:urltype] || :short][:test] }
@@ -2,38 +2,38 @@ require "spec_helper"
2
2
 
3
3
  describe Onebox::Engine::ImageOnebox do
4
4
  it "supports png" do
5
- Onebox.preview('http://www.discourse.org/images/logo.png').to_s.should match(/<img/)
5
+ expect(Onebox.preview('http://www.discourse.org/images/logo.png').to_s).to match(/<img/)
6
6
  end
7
7
 
8
8
  it "supports jpg" do
9
- Onebox.preview('http://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg').to_s.should match(/<img/)
9
+ expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg').to_s).to match(/<img/)
10
10
  end
11
11
 
12
12
  it "supports jpeg" do
13
- Onebox.preview('http://upload.wikimedia.org/wikipedia/en/b/bb/Poster.jpeg').to_s.should match(/<img/)
13
+ expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/en/b/bb/Poster.jpeg').to_s).to match(/<img/)
14
14
  end
15
15
 
16
16
  it "supports gif" do
17
- Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/5/55/Tesseract.gif').to_s.should match(/<img/)
17
+ expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/5/55/Tesseract.gif').to_s).to match(/<img/)
18
18
  end
19
19
 
20
20
  it "supports tif" do
21
- Onebox.preview('http://www.fileformat.info/format/tiff/sample/1f37bbd5603048178487ec88b1a6425b/MARBLES.tif').to_s.should match(/<img/)
21
+ expect(Onebox.preview('http://www.fileformat.info/format/tiff/sample/1f37bbd5603048178487ec88b1a6425b/MARBLES.tif').to_s).to match(/<img/)
22
22
  end
23
23
 
24
24
  it "supports bmp" do
25
- Onebox.preview('http://www.fileformat.info/format/bmp/sample/d4202a5fc22a48c388d9e1c636792cc6/LAND.BMP').to_s.should match(/<img/)
25
+ expect(Onebox.preview('http://www.fileformat.info/format/bmp/sample/d4202a5fc22a48c388d9e1c636792cc6/LAND.BMP').to_s).to match(/<img/)
26
26
  end
27
27
 
28
28
  it "supports image URLs with query parameters" do
29
- Onebox.preview('https://www.google.com/logos/doodles/2014/percy-julians-115th-birthday-born-1899-5688801926053888-hp.jpg?foo=bar').to_s.should match(/<img/)
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
30
  end
31
31
 
32
32
  it "supports protocol relative image URLs" do
33
- Onebox.preview('//www.google.com/logos/doodles/2014/percy-julians-115th-birthday-born-1899-5688801926053888-hp.jpg').to_s.should match(/<img/)
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
34
  end
35
35
 
36
36
  it "includes a direct link to the image" do
37
- Onebox.preview('http://www.discourse.org/images/logo.png').to_s.should match(/<a.*png/)
37
+ expect(Onebox.preview('http://www.discourse.org/images/logo.png').to_s).to match(/<a.*png/)
38
38
  end
39
39
  end
@@ -14,10 +14,10 @@ describe Onebox::Engine::TwitterStatusOnebox do
14
14
  expect(html).to include("http://www.peers.org/action/peers-pledgea")
15
15
  end
16
16
 
17
- it "includes timestamp" do
18
- pending
19
- expect(html).to include("6:59 PM - 1 Aug 13")
20
- end
17
+ # TODO: weird spec..
18
+ # it "includes timestamp" do
19
+ # expect(html).to include("6:59 PM - 1 Aug 13")
20
+ # end
21
21
 
22
22
  it "includes username" do
23
23
  expect(html).to include("vyki_e")
@@ -28,12 +28,10 @@ describe Onebox::Engine::TwitterStatusOnebox do
28
28
  end
29
29
 
30
30
  it "includes tweet favorite count" do
31
- pending
32
31
  expect(html).to include("")
33
32
  end
34
33
 
35
34
  it "includes retweet count" do
36
- pending
37
35
  expect(html).to include("")
38
36
  end
39
37
  end
@@ -47,7 +45,7 @@ describe Onebox::Engine::TwitterStatusOnebox do
47
45
  context "with twitter client" do
48
46
  before(:each) do
49
47
  @twitter_client = double("TwitterClient")
50
- @twitter_client.stub("status") do
48
+ allow(@twitter_client).to receive("status") do
51
49
  {
52
50
  created_at: "Fri Aug 02 01:59:30 +0000 2013",
53
51
  id: 363_116_819_147_538_433,
@@ -93,7 +91,7 @@ describe Onebox::Engine::TwitterStatusOnebox do
93
91
  lang: "en"
94
92
  }
95
93
  end
96
- @twitter_client.stub("prettify_tweet") do
94
+ allow(@twitter_client).to receive("prettify_tweet") do
97
95
  "I'm a sucker for pledges. <a href='https://twitter.com/Peers' target='_blank'>@Peers</a> Pledge <a href='https://twitter.com/search?q=%23sharingeconomy' target='_blank'>#sharingeconomy</a> <a target='_blank' href='http://www.peers.org/action/peers-pledgea/'>peers.org/action/peers-p…</a>"
98
96
  end
99
97
  Onebox.options = { twitter_client: @twitter_client }
@@ -2,30 +2,30 @@ require "spec_helper"
2
2
 
3
3
  describe Onebox::Engine::VideoOnebox do
4
4
  it "supports ogv" do
5
- Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/3/37/STS-134_launch_2.ogv').to_s.should match(/<video/)
5
+ expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/3/37/STS-134_launch_2.ogv').to_s).to match(/<video/)
6
6
  end
7
7
 
8
8
  it "supports mp4" do
9
- Onebox.preview('http://download.wavetlan.com/svv/dev/test.mp4').to_s.should match(/<video/)
9
+ expect(Onebox.preview('http://download.wavetlan.com/svv/dev/test.mp4').to_s).to match(/<video/)
10
10
  end
11
11
 
12
12
  it "supports mov" do
13
- Onebox.preview('http://download.wavetlan.com/SVV/Media/HTTP/BlackBerry.mov').to_s.should match(/<video/)
13
+ expect(Onebox.preview('http://download.wavetlan.com/SVV/Media/HTTP/BlackBerry.mov').to_s).to match(/<video/)
14
14
  end
15
15
 
16
16
  it "supports webm" do
17
- Onebox.preview('http://video.webmfiles.org/big-buck-bunny_trailer.webm').to_s.should match(/<video/)
17
+ expect(Onebox.preview('http://video.webmfiles.org/big-buck-bunny_trailer.webm').to_s).to match(/<video/)
18
18
  end
19
19
 
20
20
  it "supports URLs with query parameters" do
21
- Onebox.preview('http://video.webmfiles.org/big-buck-bunny_trailer.webm?foo=bar').to_s.should match(/<video/)
21
+ expect(Onebox.preview('http://video.webmfiles.org/big-buck-bunny_trailer.webm?foo=bar').to_s).to match(/<video/)
22
22
  end
23
23
 
24
24
  it "supports protocol relative URLs" do
25
- Onebox.preview('//video.webmfiles.org/big-buck-bunny_trailer.webm').to_s.should match(/<video/)
25
+ expect(Onebox.preview('//video.webmfiles.org/big-buck-bunny_trailer.webm').to_s).to match(/<video/)
26
26
  end
27
27
 
28
28
  it "includes a fallback direct link to the video" do
29
- Onebox.preview('http://download.wavetlan.com/svv/dev/test.mp4').to_s.should match(/<a.*mp4/)
29
+ expect(Onebox.preview('http://download.wavetlan.com/svv/dev/test.mp4').to_s).to match(/<a.*mp4/)
30
30
  end
31
31
  end
@@ -38,12 +38,12 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
38
38
 
39
39
  it "doesn't return the HTML when not in the `html_providers`" do
40
40
  Onebox::Engine::WhitelistedGenericOnebox.html_providers = []
41
- HTMLOnebox.new("http://coolsite.com").to_html.should be_nil
41
+ expect(HTMLOnebox.new("http://coolsite.com").to_html).to be_nil
42
42
  end
43
43
 
44
44
  it "returns the HMTL when in the `html_providers`" do
45
45
  Onebox::Engine::WhitelistedGenericOnebox.html_providers = ['CoolSite']
46
- HTMLOnebox.new("http://coolsite.com").to_html.should == "cool html"
46
+ expect(HTMLOnebox.new("http://coolsite.com").to_html).to eq "cool html"
47
47
  end
48
48
  end
49
49
 
@@ -56,12 +56,12 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
56
56
 
57
57
  it "doesn't rewrite URLs that arent in the list" do
58
58
  Onebox::Engine::WhitelistedGenericOnebox.rewrites = []
59
- DummyOnebox.new("http://youtube.com").to_html.should == "<iframe src='https://youtube.com/asdf'></iframe>"
59
+ expect(DummyOnebox.new("http://youtube.com").to_html).to eq "<iframe src='https://youtube.com/asdf'></iframe>"
60
60
  end
61
61
 
62
62
  it "rewrites URLs when whitelisted" do
63
63
  Onebox::Engine::WhitelistedGenericOnebox.rewrites = %w(youtube.com)
64
- DummyOnebox.new("http://youtube.com").to_html.should == "<iframe src='//youtube.com/asdf'></iframe>"
64
+ expect(DummyOnebox.new("http://youtube.com").to_html).to eq "<iframe src='//youtube.com/asdf'></iframe>"
65
65
  end
66
66
  end
67
67
 
@@ -73,8 +73,8 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
73
73
 
74
74
  it 'uses the endpoint for the url' do
75
75
  onebox = described_class.new("http://www.meetup.com/Toronto-Ember-JS-Meetup/events/219939537")
76
- onebox.raw.should_not be_nil
77
- onebox.raw[:title].should == "February EmberTO Meet-up"
76
+ expect(onebox.raw).not_to be_nil
77
+ expect(onebox.raw[:title]).to eq "February EmberTO Meet-up"
78
78
  end
79
79
  end
80
80
 
@@ -7,7 +7,7 @@ describe Onebox::Engine::YoukuOnebox do
7
7
  end
8
8
 
9
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/)
10
+ expect(Onebox.preview('http://v.youku.com/v_show/id_XNjM3MzAxNzc2.html')
11
+ .placeholder_html).to match(/<img/)
12
12
  end
13
13
  end
@@ -7,25 +7,25 @@ describe Onebox::Engine::YoutubeOnebox do
7
7
  end
8
8
 
9
9
  it "adds wmode=opaque" do
10
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
11
- .to_s.should match(/wmode=opaque/)
10
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
11
+ .to_s).to match(/wmode=opaque/)
12
12
  end
13
13
 
14
14
  it "rewrites URLs for videos to be HTTPS" do
15
15
  # match: plain HTTP and protocol agnostic
16
16
  regex = /(http:|["']\/\/)/
17
17
 
18
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
19
- .to_s.should_not match(regex)
20
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
21
- .placeholder_html.should_not match(regex)
22
- Onebox.preview('https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ')
23
- .to_s.should_not match(regex)
18
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
19
+ .to_s).not_to match(regex)
20
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
21
+ .placeholder_html).not_to match(regex)
22
+ expect(Onebox.preview('https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ')
23
+ .to_s).not_to match(regex)
24
24
  end
25
25
 
26
26
  it "can onebox a channel page" do
27
- Onebox.preview('https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ')
28
- .to_s.should match(/Google Chrome/)
27
+ expect(Onebox.preview('https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ')
28
+ .to_s).to match(/Google Chrome/)
29
29
  end
30
30
 
31
31
  it "can onebox a playlist" do
@@ -42,48 +42,48 @@ describe Onebox::Engine::YoutubeOnebox do
42
42
 
43
43
  it "does not fail if we cannot get the video ID from the URL" do
44
44
  # TODO this test no longer makes sense - the video ID is successfully retrieved and no fakeweb request is made
45
- Onebox.preview('http://www.youtube.com/watch?feature=player_embedded&v=21Lk4YiASMo')
46
- .to_s.should match(/embed/)
45
+ expect(Onebox.preview('http://www.youtube.com/watch?feature=player_embedded&v=21Lk4YiASMo')
46
+ .to_s).to match(/embed/)
47
47
  end
48
48
 
49
49
  it "returns an image as the placeholder" do
50
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
51
- .placeholder_html.should match(/<img/)
50
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
51
+ .placeholder_html).to match(/<img/)
52
52
  end
53
53
 
54
54
  it "passes the playlist ID through" do
55
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&list=UUQau-O2C0kGJpR3_CHBTGbw&index=1')
56
- .to_s.should match(/UUQau-O2C0kGJpR3_CHBTGbw/)
55
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&list=UUQau-O2C0kGJpR3_CHBTGbw&index=1')
56
+ .to_s).to match(/UUQau-O2C0kGJpR3_CHBTGbw/)
57
57
  end
58
58
 
59
59
  it "filters out nonsense parameters" do
60
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&potential[]=exploit&potential[]=fun')
61
- .to_s.should_not match(/potential|exploit|fun/)
60
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&potential[]=exploit&potential[]=fun')
61
+ .to_s).not_to match(/potential|exploit|fun/)
62
62
  end
63
63
 
64
64
  it "converts time strings into a &start= parameter" do
65
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=3782')
66
- .to_s.should match(/start=3782/)
67
- Onebox.preview('https://www.youtube.com/watch?start=1h3m2s&v=21Lk4YiASMo')
68
- .to_s.should match(/start=3782/)
69
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&t=1h3m2s')
70
- .to_s.should match(/start=3782/)
71
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=1h3m2s')
72
- .to_s.should match(/start=3782/)
73
- Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo#t=1h3m2s')
74
- .to_s.should match(/start=3782/)
65
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=3782')
66
+ .to_s).to match(/start=3782/)
67
+ expect(Onebox.preview('https://www.youtube.com/watch?start=1h3m2s&v=21Lk4YiASMo')
68
+ .to_s).to match(/start=3782/)
69
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&t=1h3m2s')
70
+ .to_s).to match(/start=3782/)
71
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=1h3m2s')
72
+ .to_s).to match(/start=3782/)
73
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo#t=1h3m2s')
74
+ .to_s).to match(/start=3782/)
75
75
  end
76
76
 
77
77
  it "allows both start and end" do
78
- preview = Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=2m&end=3m').to_s
79
- preview.should match(/start=120/)
80
- preview.should match(/end=180/)
78
+ preview = expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=2m&end=3m').to_s)
79
+ preview.to match(/start=120/)
80
+ preview.to match(/end=180/)
81
81
  end
82
82
 
83
83
  it "permits looping videos" do
84
- preview = Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&loop').to_s
85
- preview.should match(/loop=1/)
86
- preview.should match(/playlist=21Lk4YiASMo/)
84
+ preview = expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&loop').to_s)
85
+ preview.to match(/loop=1/)
86
+ preview.to match(/playlist=21Lk4YiASMo/)
87
87
  end
88
88
  end
89
89
 
@@ -18,7 +18,7 @@ describe Onebox::Engine do
18
18
  end
19
19
 
20
20
  describe "#link" do
21
- before { Onebox::View.any_instance.stub(:template) { %|this shold be a template| } }
21
+ before { allow(Onebox::View).to receive(:template) { %|this shold be a template| } }
22
22
 
23
23
  it "escapes `link`" do
24
24
  html = OneboxEngineExample.new(%|http://foo.com" onscript="alert('foo')|).to_html
@@ -16,9 +16,7 @@ describe Onebox::Layout do
16
16
 
17
17
  context "when template exists in directory_b" do
18
18
  before(:each) do
19
- allow_any_instance_of(described_class).to receive(:template?) do |path|
20
- path == "directory_b"
21
- end
19
+ allow_any_instance_of(described_class).to receive(:template?) { |_,path| path == "directory_b" }
22
20
  end
23
21
 
24
22
  it "returns directory_b" do
@@ -28,9 +26,7 @@ describe Onebox::Layout do
28
26
 
29
27
  context "when template exists in directory_a" do
30
28
  before(:each) do
31
- allow_any_instance_of(described_class).to receive(:template?) do |path|
32
- path == "directory_a"
33
- end
29
+ allow_any_instance_of(described_class).to receive(:template?) { |_,path| path == "directory_a" }
34
30
  end
35
31
 
36
32
  it "returns directory_a" do
@@ -16,7 +16,7 @@ describe Onebox::Matcher do
16
16
 
17
17
  it "finds an engine" do
18
18
  matcher.stubs(:ordered_engines).returns([TestEngine])
19
- matcher.oneboxed.should_not be_nil
19
+ expect(matcher.oneboxed).not_to be_nil
20
20
  end
21
21
  end
22
22
 
@@ -26,7 +26,7 @@ describe Onebox::Matcher do
26
26
 
27
27
  it "doesn't find an engine" do
28
28
  matcher.stubs(:ordered_engines).returns([TestEngine])
29
- matcher.oneboxed.should be_nil
29
+ expect(matcher.oneboxed).to be_nil
30
30
  end
31
31
  end
32
32
 
@@ -36,7 +36,7 @@ describe Onebox::Matcher do
36
36
 
37
37
  it "it finds an engine" do
38
38
  matcher.stubs(:ordered_engines).returns([TestEngine])
39
- matcher.oneboxed.should_not be_nil
39
+ expect(matcher.oneboxed).not_to be_nil
40
40
  end
41
41
  end
42
42
 
@@ -46,7 +46,7 @@ describe Onebox::Matcher do
46
46
 
47
47
  it "it finds an engine" do
48
48
  matcher.stubs(:ordered_engines).returns([TestEngine])
49
- matcher.oneboxed.should_not be_nil
49
+ expect(matcher.oneboxed).not_to be_nil
50
50
  end
51
51
  end
52
52
 
@@ -48,11 +48,11 @@ describe Onebox do
48
48
  Onebox::Engine::WhitelistedGenericOnebox.whitelist = %w(youtube.com)
49
49
  end
50
50
  it "has no matcher for a made up url" do
51
- expect(Onebox.has_matcher?("http://wow.com/omg/doge")).to be_false
51
+ expect(Onebox.has_matcher?("http://wow.com/omg/doge")).to be false
52
52
  end
53
53
 
54
54
  it "has a matcher for a real site" do
55
- expect(Onebox.has_matcher?("http://www.youtube.com/watch?v=azaIE6QSMUs")).to be_true
55
+ expect(Onebox.has_matcher?("http://www.youtube.com/watch?v=azaIE6QSMUs")).to be true
56
56
  end
57
57
  end
58
58
  end
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.17
4
+ version: 1.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,260 +10,260 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-05-07 00:00:00.000000000 Z
13
+ date: 2015-05-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: '1.7'
21
+ version: '1.11'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ~>
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '1.7'
28
+ version: '1.11'
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: mustache
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
- - - ~>
33
+ - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: '0.99'
35
+ version: '0'
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
- - - ~>
40
+ - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: '0.99'
42
+ version: '0'
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: nokogiri
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ~>
47
+ - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: 1.6.1
49
+ version: 1.6.6
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ~>
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: 1.6.1
56
+ version: 1.6.6
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: moneta
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ~>
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '0.7'
63
+ version: '0.8'
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
- - - ~>
68
+ - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '0.7'
70
+ version: '0.8'
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: bundler
73
73
  requirement: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ~>
75
+ - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '1.3'
77
+ version: '1.7'
78
78
  type: :development
79
79
  prerelease: false
80
80
  version_requirements: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ~>
82
+ - - "~>"
83
83
  - !ruby/object:Gem::Version
84
- version: '1.3'
84
+ version: '1.7'
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: rake
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - ~>
89
+ - - "~>"
90
90
  - !ruby/object:Gem::Version
91
- version: '10.0'
91
+ version: '10.4'
92
92
  type: :development
93
93
  prerelease: false
94
94
  version_requirements: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - ~>
96
+ - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: '10.0'
98
+ version: '10.4'
99
99
  - !ruby/object:Gem::Dependency
100
100
  name: rspec
101
101
  requirement: !ruby/object:Gem::Requirement
102
102
  requirements:
103
- - - ~>
103
+ - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: '2.14'
105
+ version: '3.2'
106
106
  type: :development
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
- - - ~>
110
+ - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: '2.14'
112
+ version: '3.2'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: yard
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ~>
117
+ - - "~>"
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0.8'
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ~>
124
+ - - "~>"
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0.8'
127
127
  - !ruby/object:Gem::Dependency
128
128
  name: fakeweb
129
129
  requirement: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ~>
131
+ - - "~>"
132
132
  - !ruby/object:Gem::Version
133
133
  version: '1.3'
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
- - - ~>
138
+ - - "~>"
139
139
  - !ruby/object:Gem::Version
140
140
  version: '1.3'
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: pry
143
143
  requirement: !ruby/object:Gem::Requirement
144
144
  requirements:
145
- - - ~>
145
+ - - "~>"
146
146
  - !ruby/object:Gem::Version
147
- version: '0.9'
147
+ version: '0.10'
148
148
  type: :development
149
149
  prerelease: false
150
150
  version_requirements: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - ~>
152
+ - - "~>"
153
153
  - !ruby/object:Gem::Version
154
- version: '0.9'
154
+ version: '0.10'
155
155
  - !ruby/object:Gem::Dependency
156
156
  name: mocha
157
157
  requirement: !ruby/object:Gem::Requirement
158
158
  requirements:
159
- - - ~>
159
+ - - "~>"
160
160
  - !ruby/object:Gem::Version
161
- version: '0.14'
161
+ version: '1.1'
162
162
  type: :development
163
163
  prerelease: false
164
164
  version_requirements: !ruby/object:Gem::Requirement
165
165
  requirements:
166
- - - ~>
166
+ - - "~>"
167
167
  - !ruby/object:Gem::Version
168
- version: '0.14'
168
+ version: '1.1'
169
169
  - !ruby/object:Gem::Dependency
170
170
  name: rubocop
171
171
  requirement: !ruby/object:Gem::Requirement
172
172
  requirements:
173
- - - ~>
173
+ - - "~>"
174
174
  - !ruby/object:Gem::Version
175
- version: '0.11'
175
+ version: '0.30'
176
176
  type: :development
177
177
  prerelease: false
178
178
  version_requirements: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - ~>
180
+ - - "~>"
181
181
  - !ruby/object:Gem::Version
182
- version: '0.11'
182
+ version: '0.30'
183
183
  - !ruby/object:Gem::Dependency
184
184
  name: twitter
185
185
  requirement: !ruby/object:Gem::Requirement
186
186
  requirements:
187
- - - ~>
187
+ - - "~>"
188
188
  - !ruby/object:Gem::Version
189
189
  version: '4.8'
190
190
  type: :development
191
191
  prerelease: false
192
192
  version_requirements: !ruby/object:Gem::Requirement
193
193
  requirements:
194
- - - ~>
194
+ - - "~>"
195
195
  - !ruby/object:Gem::Version
196
196
  version: '4.8'
197
197
  - !ruby/object:Gem::Dependency
198
198
  name: guard-rspec
199
199
  requirement: !ruby/object:Gem::Requirement
200
200
  requirements:
201
- - - ~>
201
+ - - "~>"
202
202
  - !ruby/object:Gem::Version
203
203
  version: 4.2.8
204
204
  type: :development
205
205
  prerelease: false
206
206
  version_requirements: !ruby/object:Gem::Requirement
207
207
  requirements:
208
- - - ~>
208
+ - - "~>"
209
209
  - !ruby/object:Gem::Version
210
210
  version: 4.2.8
211
211
  - !ruby/object:Gem::Dependency
212
212
  name: sinatra
213
213
  requirement: !ruby/object:Gem::Requirement
214
214
  requirements:
215
- - - ~>
215
+ - - "~>"
216
216
  - !ruby/object:Gem::Version
217
217
  version: '1.4'
218
218
  type: :development
219
219
  prerelease: false
220
220
  version_requirements: !ruby/object:Gem::Requirement
221
221
  requirements:
222
- - - ~>
222
+ - - "~>"
223
223
  - !ruby/object:Gem::Version
224
224
  version: '1.4'
225
225
  - !ruby/object:Gem::Dependency
226
226
  name: sinatra-contrib
227
227
  requirement: !ruby/object:Gem::Requirement
228
228
  requirements:
229
- - - ~>
229
+ - - "~>"
230
230
  - !ruby/object:Gem::Version
231
231
  version: '1.4'
232
232
  type: :development
233
233
  prerelease: false
234
234
  version_requirements: !ruby/object:Gem::Requirement
235
235
  requirements:
236
- - - ~>
236
+ - - "~>"
237
237
  - !ruby/object:Gem::Version
238
238
  version: '1.4'
239
239
  - !ruby/object:Gem::Dependency
240
240
  name: haml
241
241
  requirement: !ruby/object:Gem::Requirement
242
242
  requirements:
243
- - - ~>
243
+ - - "~>"
244
244
  - !ruby/object:Gem::Version
245
245
  version: '4.0'
246
246
  type: :development
247
247
  prerelease: false
248
248
  version_requirements: !ruby/object:Gem::Requirement
249
249
  requirements:
250
- - - ~>
250
+ - - "~>"
251
251
  - !ruby/object:Gem::Version
252
252
  version: '4.0'
253
253
  - !ruby/object:Gem::Dependency
254
254
  name: listen
255
255
  requirement: !ruby/object:Gem::Requirement
256
256
  requirements:
257
- - - '='
257
+ - - "~>"
258
258
  - !ruby/object:Gem::Version
259
- version: 2.6.0
259
+ version: 2.10.0
260
260
  type: :development
261
261
  prerelease: false
262
262
  version_requirements: !ruby/object:Gem::Requirement
263
263
  requirements:
264
- - - '='
264
+ - - "~>"
265
265
  - !ruby/object:Gem::Version
266
- version: 2.6.0
266
+ version: 2.10.0
267
267
  description: A gem for turning URLs into previews.
268
268
  email:
269
269
  - holla@jzeta.com
@@ -273,11 +273,11 @@ executables: []
273
273
  extensions: []
274
274
  extra_rdoc_files: []
275
275
  files:
276
- - .gitignore
277
- - .rspec
278
- - .rubocop.yml
279
- - .ruby-gemset
280
- - .travis.yml
276
+ - ".gitignore"
277
+ - ".rspec"
278
+ - ".rubocop.yml"
279
+ - ".ruby-gemset"
280
+ - ".travis.yml"
281
281
  - Gemfile
282
282
  - Guardfile
283
283
  - LICENSE.txt
@@ -399,17 +399,17 @@ require_paths:
399
399
  - lib
400
400
  required_ruby_version: !ruby/object:Gem::Requirement
401
401
  requirements:
402
- - - '>='
402
+ - - ">="
403
403
  - !ruby/object:Gem::Version
404
404
  version: '0'
405
405
  required_rubygems_version: !ruby/object:Gem::Requirement
406
406
  requirements:
407
- - - '>='
407
+ - - ">="
408
408
  - !ruby/object:Gem::Version
409
409
  version: '0'
410
410
  requirements: []
411
411
  rubyforge_project:
412
- rubygems_version: 2.0.14
412
+ rubygems_version: 2.4.3
413
413
  signing_key:
414
414
  specification_version: 4
415
415
  summary: A gem for turning URLs into previews.
@@ -463,4 +463,3 @@ test_files:
463
463
  - spec/lib/onebox_spec.rb
464
464
  - spec/spec_helper.rb
465
465
  - spec/support/html_spec_helper.rb
466
- has_rdoc: