link_oracle 0.1.8 → 0.1.9
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.
- checksums.yaml +4 -4
- data/lib/link_oracle/request.rb +3 -0
- data/lib/link_oracle/version.rb +1 -1
- data/spec/link_oracle/request_spec.rb +47 -43
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22de0311b5c6ff2460a3b3af8334693daebcaba3
|
4
|
+
data.tar.gz: 5c4e063fcb0e5723afc2ae015d956753684629e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d142a141bfb054ba44fafc6570d356b1697e740863474c8d9e46540c4daeebb28f483524aff3bdeb3dd536e882387178de9caed11cbca591e508a30389d8c64a
|
7
|
+
data.tar.gz: 52dcbb19795887a351118f17d552ac9f34b206ef7562f1584eaac1ba07e372cf894d97bb98090d946e195363641353bf69221ae04fd0aafda9944f111785bb80
|
data/lib/link_oracle/request.rb
CHANGED
@@ -52,6 +52,8 @@ class LinkOracle
|
|
52
52
|
c
|
53
53
|
rescue Curl::Err::HostResolutionError
|
54
54
|
raise ServerNotFound
|
55
|
+
rescue Curl::Err::SSLCACertificateError
|
56
|
+
raise BadSslCertificate
|
55
57
|
end
|
56
58
|
|
57
59
|
def error_class
|
@@ -75,4 +77,5 @@ class LinkOracle
|
|
75
77
|
class BadThingsHappened < StandardError; end
|
76
78
|
class InvalidUrl < StandardError; end
|
77
79
|
class ParsingError < StandardError; end
|
80
|
+
class BadSslCertificate < StandardError ; end
|
78
81
|
end
|
data/lib/link_oracle/version.rb
CHANGED
@@ -29,62 +29,66 @@ describe LinkOracle::Request do
|
|
29
29
|
describe '#parsed_url' do
|
30
30
|
context 'request failures' do
|
31
31
|
before do
|
32
|
-
stub_request(:
|
32
|
+
stub_request(:get, url).to_return(response_hash)
|
33
33
|
end
|
34
34
|
|
35
|
-
context '
|
36
|
-
|
37
|
-
let(:code) { 404 }
|
35
|
+
context 'response code is 404' do
|
36
|
+
let(:code) { 404 }
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
38
|
+
it 'should raise PageNotFound' do
|
39
|
+
expect {
|
40
|
+
requester.parsed_url
|
41
|
+
}.to raise_error(LinkOracle::PageNotFound)
|
44
42
|
end
|
43
|
+
end
|
45
44
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
expect {
|
53
|
-
requester.parsed_url
|
54
|
-
}.to raise_error(LinkOracle::ServerNotFound)
|
55
|
-
end
|
45
|
+
context 'nonexistant url' do
|
46
|
+
it 'should raise ServerNotFound' do
|
47
|
+
stub_request(:get, url).to_raise(Curl::Err::HostResolutionError)
|
48
|
+
expect {
|
49
|
+
requester.parsed_url
|
50
|
+
}.to raise_error(LinkOracle::ServerNotFound)
|
56
51
|
end
|
52
|
+
end
|
57
53
|
|
58
|
-
|
59
|
-
|
54
|
+
context 'response code is 403' do
|
55
|
+
let(:code) { 403 }
|
60
56
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
57
|
+
it 'should raise PermissionDenied' do
|
58
|
+
expect {
|
59
|
+
requester.parsed_url
|
60
|
+
}.to raise_error(LinkOracle::PermissionDenied)
|
66
61
|
end
|
62
|
+
end
|
67
63
|
|
68
|
-
|
69
|
-
|
64
|
+
context 'response code is weird' do
|
65
|
+
let(:code) { 42 }
|
70
66
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
67
|
+
it 'should raise BadThingsHappened' do
|
68
|
+
expect {
|
69
|
+
requester.parsed_url
|
70
|
+
}.to raise_error(LinkOracle::BadThingsHappened)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "when the server's SSL certificate is untrusted" do
|
75
|
+
it "raises BadSslCertificate" do
|
76
|
+
stub_request(:get, url).to_raise(Curl::Err::SSLCACertificateError)
|
77
|
+
expect do
|
78
|
+
requester.parsed_url
|
79
|
+
end.to raise_error(LinkOracle::BadSslCertificate)
|
76
80
|
end
|
81
|
+
end
|
77
82
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
83
|
+
context 'parsing goes awry' do
|
84
|
+
before do
|
85
|
+
::Nokogiri::HTML.should_receive(:parse).and_raise(ArgumentError)
|
86
|
+
end
|
82
87
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
+
it 'should raise ParsingError' do
|
89
|
+
expect {
|
90
|
+
requester.parsed_url
|
91
|
+
}.to raise_error(LinkOracle::ParsingError)
|
88
92
|
end
|
89
93
|
end
|
90
94
|
end
|
@@ -112,7 +116,7 @@ describe LinkOracle::Request do
|
|
112
116
|
|
113
117
|
context "the url has weird characters in it" do
|
114
118
|
before do
|
115
|
-
stub_request(:
|
119
|
+
stub_request(:get, url).to_return(response_hash)
|
116
120
|
end
|
117
121
|
|
118
122
|
let(:url) { 'http://www.autoblog.com/2014/09/26/porsche-911-nissan-gtr-world-greatest-drag-race-video/?icid=autos|latest-auto-news|content' }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: link_oracle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Cooper
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2014-11-
|
16
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: nokogiri
|