metainspector 5.5.0 → 5.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/meta_inspector/document.rb +2 -0
- data/lib/meta_inspector/parsers/texts.rb +5 -13
- data/lib/meta_inspector/request.rb +7 -1
- data/lib/meta_inspector/version.rb +1 -1
- data/spec/document_spec.rb +6 -0
- data/spec/fixtures/invalid_utf8_byte_seq.response +2618 -0
- data/spec/fixtures/title_best_choice.response +1 -1
- data/spec/meta_inspector/texts_spec.rb +2 -8
- data/spec/request_spec.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- metadata +3 -2
@@ -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
|
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
|
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
|
data/spec/request_spec.rb
CHANGED
@@ -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
|
data/spec/spec_helper.rb
CHANGED
@@ -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.
|
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-
|
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
|