link_oracle 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- 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 +19 -4
- 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: d19780fb7f9cd2688937b8cc94e32f3c82b514ac
|
4
|
+
data.tar.gz: d4ebf911932fc368456526e26c19544b8e843762
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36a66ac4d7f24a076fff08a21e892f365d8749da383cf3e006340c73fda2fb8f3ee4a0a626720561001850523c4e1dd3d176197656a5b0a9511279329ddb7d7c
|
7
|
+
data.tar.gz: d30bbc6cbbd2abf2f2eb397b0648f6ee1921793d55e715ceb51cbeab4e751e413a7ec446c25b9a6e4e3426a8b6f86710b24f4f8e28d4fb7de0dcea54ac0c1f4e
|
data/lib/link_oracle/request.rb
CHANGED
@@ -50,6 +50,8 @@ class LinkOracle
|
|
50
50
|
c.perform
|
51
51
|
end
|
52
52
|
c
|
53
|
+
rescue Curl::Err::HostResolutionError
|
54
|
+
raise ServerNotFound
|
53
55
|
end
|
54
56
|
|
55
57
|
def error_class
|
@@ -68,6 +70,7 @@ class LinkOracle
|
|
68
70
|
end
|
69
71
|
|
70
72
|
class PageNotFound < StandardError; end
|
73
|
+
class ServerNotFound < StandardError; end
|
71
74
|
class PermissionDenied < StandardError; end
|
72
75
|
class BadThingsHappened < StandardError; end
|
73
76
|
class InvalidUrl < StandardError; end
|
data/lib/link_oracle/version.rb
CHANGED
@@ -26,14 +26,13 @@ describe LinkOracle::Request do
|
|
26
26
|
</html>"
|
27
27
|
}
|
28
28
|
|
29
|
-
|
30
|
-
describe 'perform' do
|
29
|
+
describe '#parsed_url' do
|
31
30
|
context 'request failures' do
|
32
31
|
before do
|
33
32
|
stub_request(:any, url).to_return(response_hash)
|
34
33
|
end
|
35
34
|
|
36
|
-
context '
|
35
|
+
context 'page not found' do
|
37
36
|
context 'response code is 404' do
|
38
37
|
let(:code) { 404 }
|
39
38
|
|
@@ -44,6 +43,18 @@ describe LinkOracle::Request do
|
|
44
43
|
end
|
45
44
|
end
|
46
45
|
|
46
|
+
context 'nonexistant url' do
|
47
|
+
it 'should raise ServerNotFound' do
|
48
|
+
curl = double('curl', "follow_location=" => true, "max_redirects=" => true)
|
49
|
+
allow(curl).to receive(:perform).and_raise(Curl::Err::HostResolutionError)
|
50
|
+
allow(Curl::Easy).to receive(:new).and_return(curl)
|
51
|
+
|
52
|
+
expect {
|
53
|
+
requester.parsed_url
|
54
|
+
}.to raise_error(LinkOracle::ServerNotFound)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
47
58
|
context 'response code is 403' do
|
48
59
|
let(:code) { 403 }
|
49
60
|
|
@@ -100,12 +111,16 @@ describe LinkOracle::Request do
|
|
100
111
|
end
|
101
112
|
|
102
113
|
context "the url has weird characters in it" do
|
114
|
+
before do
|
115
|
+
stub_request(:any, url).to_return(response_hash)
|
116
|
+
end
|
117
|
+
|
103
118
|
let(:url) { 'http://www.autoblog.com/2014/09/26/porsche-911-nissan-gtr-world-greatest-drag-race-video/?icid=autos|latest-auto-news|content' }
|
104
119
|
|
105
120
|
it "should encode and not raise an error" do
|
106
121
|
expect {
|
107
122
|
requester.parsed_url
|
108
|
-
}.to_not raise_error
|
123
|
+
}.to_not raise_error
|
109
124
|
end
|
110
125
|
end
|
111
126
|
end
|
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.7
|
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-
|
16
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: nokogiri
|