metainspector 5.5.0 → 5.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,7 +27,7 @@ Connection: keep-alive
27
27
 
28
28
  </title>
29
29
 
30
- <meta property="og:title" content="This OG title is long, but not long enough" />
30
+ <meta property="og:title" content="This OG title is the best choice, as per web standards." />
31
31
 
32
32
 
33
33
 
@@ -27,9 +27,9 @@ describe MetaInspector do
27
27
  expect(page.best_title).to eq('This title came from the first h1')
28
28
  end
29
29
 
30
- it "should choose the longest candidate from the available options" do
30
+ it "should choose the best candidate from the available options" do
31
31
  page = MetaInspector.new('http://example.com/title_best_choice')
32
- expect(page.best_title).to eq('This title came from the first h1 and should be the longest of them all, so should be chosen')
32
+ expect(page.best_title).to eq('This OG title is the best choice, as per web standards.')
33
33
  end
34
34
 
35
35
  it "should strip leading and trailing whitespace and all line breaks" do
@@ -41,12 +41,6 @@ describe MetaInspector do
41
41
  page = MetaInspector.new('http://example.com/title_not_present')
42
42
  expect(page.best_title).to be(nil)
43
43
  end
44
-
45
- it "should use the og:title for youtube in preference to h1" do
46
- #youtube has a h1 value of 'This video is unavailable.' which is unhelpful
47
- page = MetaInspector.new('http://www.youtube.com/watch?v=short_title')
48
- expect(page.best_title).to eq('Angular 2 Forms')
49
- end
50
44
  end
51
45
 
52
46
  describe '#author' do
@@ -13,6 +13,22 @@ describe MetaInspector::Request do
13
13
 
14
14
  expect(page_request.read[0..14]).to eq("<!DOCTYPE html>")
15
15
  end
16
+
17
+ it "can have a forced encoding" do
18
+ page_request =
19
+ MetaInspector::Request.new(url('http://example.com/invalid_utf8_byte_seq'))
20
+
21
+ expect do
22
+ page_request.read
23
+ end.to raise_error(MetaInspector::RequestError, "invalid byte sequence in UTF-8")
24
+
25
+ page_request_with_forced_encoding =
26
+ MetaInspector::Request.new(url('http://example.com/invalid_utf8_byte_seq'), encoding: "UTF-8")
27
+
28
+ expect do
29
+ page_request_with_forced_encoding.read
30
+ end.not_to raise_error
31
+ end
16
32
  end
17
33
 
18
34
  describe "response" do
@@ -30,6 +30,7 @@ RSpec.configure do |config|
30
30
  stub_request(:get, "http://example.com/empty").to_return(fixture_file("empty_page.response"))
31
31
  stub_request(:get, "http://example.com/head_links").to_return(fixture_file("head_links.response"))
32
32
  stub_request(:get, "http://example.com/invalid_byte_seq").to_return(fixture_file("invalid_byte_seq.response"))
33
+ stub_request(:get, "http://example.com/invalid_utf8_byte_seq").to_return(fixture_file("invalid_utf8_byte_seq.response"))
33
34
  stub_request(:get, "http://example.com/invalid_href").to_return(fixture_file("invalid_href.response"))
34
35
  stub_request(:get, "http://example.com/largest_image_in_html").to_return(fixture_file("largest_image_in_html.response"))
35
36
  stub_request(:get, "http://example.com/largest_image_using_image_size").to_return(fixture_file("largest_image_using_image_size.response"))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metainspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.0
4
+ version: 5.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaime Iniesta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-15 00:00:00.000000000 Z
11
+ date: 2018-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -284,6 +284,7 @@ files:
284
284
  - spec/fixtures/international.response
285
285
  - spec/fixtures/invalid_byte_seq.response
286
286
  - spec/fixtures/invalid_href.response
287
+ - spec/fixtures/invalid_utf8_byte_seq.response
287
288
  - spec/fixtures/iteh.at.response
288
289
  - spec/fixtures/largest_image_in_html.response
289
290
  - spec/fixtures/largest_image_using_image_size.response