utterson 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/spec/utterson_spec.rb +38 -28
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 535d62e57f06b6f95ca5948cf2f235ff41e0dc05
|
4
|
+
data.tar.gz: 1e8098ec08f238c880596326d689d9272855793e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcbfe2cb045061aedae22640f0042529a934c9dce5ca5bc59e7c1e6ca1419f7d04aadf28581524a15cc7b4ef63954c4d105ef6e2862e09bdc495fc14d3fce193
|
7
|
+
data.tar.gz: 2f11619c7568d1bf885493eb384aafc3a540ef8de6a6e109734bb04ece5027dbf6fc5016dab6c0fe872e20f0b5f9c991329deea6813a7e8a7470cd0f3eaa3864
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Simple utility to traverse directory of html files and check links in them.
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/iiska/utterson.png)](https://travis-ci.org/iiska/utterson)
|
3
|
+
[![Build Status](https://travis-ci.org/iiska/utterson.png)](https://travis-ci.org/iiska/utterson) [![Dependency Status](https://gemnasium.com/iiska/utterson.png)](https://gemnasium.com/iiska/utterson)
|
4
4
|
|
5
5
|
## Getting started
|
6
6
|
|
data/spec/utterson_spec.rb
CHANGED
@@ -34,105 +34,115 @@ describe Utterson do
|
|
34
34
|
|
35
35
|
describe "#check_uri" do
|
36
36
|
let(:u) {Utterson.new}
|
37
|
+
let(:html_file) {"file.html"}
|
37
38
|
|
38
39
|
it "should use remote checking for http protocol" do
|
40
|
+
url = "http://example.com"
|
39
41
|
u.stub(:check_remote_uri) {}
|
40
|
-
u.should_receive(:check_remote_uri).with(
|
41
|
-
u.check_uri(
|
42
|
+
u.should_receive(:check_remote_uri).with(url, html_file)
|
43
|
+
u.check_uri(url, html_file)
|
42
44
|
end
|
43
45
|
|
44
46
|
it "should use remote checking for https protocol" do
|
47
|
+
url = "https://example.com"
|
45
48
|
u.stub(:check_remote_uri) {}
|
46
|
-
u.should_receive(:check_remote_uri).with(
|
47
|
-
u.check_uri(
|
49
|
+
u.should_receive(:check_remote_uri).with(url, html_file)
|
50
|
+
u.check_uri(url, html_file)
|
48
51
|
end
|
49
52
|
|
50
53
|
it "should use remote checking when only // is specified" do
|
54
|
+
url = "//example.com"
|
51
55
|
u.stub(:check_remote_uri) {}
|
52
|
-
u.should_receive(:check_remote_uri).with(
|
53
|
-
u.check_uri(
|
56
|
+
u.should_receive(:check_remote_uri).with(url, html_file)
|
57
|
+
u.check_uri(url, html_file)
|
54
58
|
end
|
55
59
|
|
56
60
|
it "should use local checking for relative uris" do
|
61
|
+
url = "../file.html"
|
57
62
|
u.stub(:check_local_uri) {}
|
58
|
-
u.should_receive(:check_local_uri).with(
|
59
|
-
u.check_uri(
|
63
|
+
u.should_receive(:check_local_uri).with(url, html_file)
|
64
|
+
u.check_uri(url, html_file)
|
60
65
|
end
|
61
66
|
end
|
62
67
|
|
63
68
|
describe "#check_local_uri" do
|
64
69
|
let(:u) {Utterson.new(dir: "spec/fixtures/dir-structure")}
|
70
|
+
let(:html_file) {"spec/fixtures/dir-structure/1.htm"}
|
65
71
|
|
66
72
|
it "should not assign error info if file exists" do
|
67
|
-
u.check_local_uri("../sample.html",
|
73
|
+
u.check_local_uri("../sample.html", html_file)
|
68
74
|
u.errors.should be_empty
|
69
75
|
end
|
70
76
|
|
71
77
|
it "should assign error info if file doesn't exist" do
|
72
|
-
|
73
|
-
u.
|
78
|
+
url = "../sample_not_found.html"
|
79
|
+
u.check_local_uri(url, html_file)
|
80
|
+
u.errors[html_file].should == {url => "File not found"}
|
74
81
|
end
|
75
82
|
|
76
83
|
it "should use root directory when urls start with /" do
|
77
|
-
u2 = Utterson.new(dir: "spec/fixtures/dir-structure",
|
78
|
-
|
84
|
+
u2 = Utterson.new(dir: "spec/fixtures/dir-structure",
|
85
|
+
root: "spec/fixtures")
|
86
|
+
u2.check_local_uri("/sample.html", html_file)
|
79
87
|
u2.errors.should be_empty
|
80
88
|
end
|
81
89
|
|
82
90
|
it "should handle target directory as root for urls starting with / if root is no available" do
|
83
|
-
u.check_local_uri("/2.html",
|
91
|
+
u.check_local_uri("/2.html", html_file)
|
84
92
|
u.errors.should be_empty
|
85
93
|
end
|
86
94
|
|
87
95
|
it "should ignore query string when checking local files" do
|
88
|
-
u.check_local_uri("2.html?queryparam=value",
|
96
|
+
u.check_local_uri("2.html?queryparam=value", html_file)
|
89
97
|
u.errors.should be_empty
|
90
98
|
end
|
91
99
|
end
|
92
100
|
|
93
101
|
describe "#check_remote_uri" do
|
94
102
|
let(:u) {Utterson.new}
|
103
|
+
let(:html_file) {"test.html"}
|
104
|
+
let(:url) {"http://example.com/index.html"}
|
95
105
|
|
96
106
|
it "should not assign error info if request is successfull" do
|
97
|
-
stub_request(:head,
|
107
|
+
stub_request(:head, url).
|
98
108
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
99
109
|
to_return(:status => 200, :body => "", :headers => {})
|
100
|
-
u.check_remote_uri(
|
110
|
+
u.check_remote_uri(url, html_file)
|
101
111
|
u.errors.should be_empty
|
102
112
|
end
|
103
113
|
|
104
114
|
it "should assign error info if there is error response" do
|
105
|
-
stub_request(:head,
|
115
|
+
stub_request(:head, url).
|
106
116
|
with(:headers => {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
|
107
117
|
to_return(:status => 404, :body => "", :headers => {})
|
108
|
-
u.check_remote_uri(
|
118
|
+
u.check_remote_uri(url, html_file)
|
109
119
|
puts u.errors.inspect
|
110
|
-
u.errors[
|
111
|
-
u.errors[
|
120
|
+
u.errors[html_file].should_not be_empty
|
121
|
+
u.errors[html_file][url].instance_of?(Net::HTTPNotFound).should be_true
|
112
122
|
end
|
113
123
|
|
114
124
|
it "should add error status from buffer timeouts" do
|
115
|
-
stub_request(:head,
|
116
|
-
u.check_remote_uri(
|
125
|
+
stub_request(:head, url).to_timeout
|
126
|
+
u.check_remote_uri(url, html_file)
|
117
127
|
u.errors.should_not be_empty
|
118
128
|
end
|
119
129
|
|
120
130
|
it "should add error status from connection timeouts" do
|
121
|
-
stub_request(:head,
|
122
|
-
u.check_remote_uri(
|
131
|
+
stub_request(:head, url).to_raise(Errno::ETIMEDOUT)
|
132
|
+
u.check_remote_uri(url, html_file)
|
123
133
|
u.errors.should_not be_empty
|
124
134
|
end
|
125
135
|
|
126
136
|
it "shoud add error status from name resolution errors" do
|
127
|
-
stub_request(:head,
|
137
|
+
stub_request(:head, url).
|
128
138
|
to_raise(SocketError.new('getaddrinfo: Name or service not known'))
|
129
|
-
u.check_remote_uri(
|
139
|
+
u.check_remote_uri(url, html_file)
|
130
140
|
u.errors.should_not be_empty
|
131
141
|
end
|
132
142
|
|
133
143
|
it "shoud add error status when invalid URI" do
|
134
144
|
URI.stub(:new).and_raise(URI::InvalidURIError)
|
135
|
-
u.check_remote_uri("http://invalid_uri",
|
145
|
+
u.check_remote_uri("http://invalid_uri", html_file)
|
136
146
|
u.errors.should_not be_empty
|
137
147
|
end
|
138
148
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utterson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juhamatti Niemelä
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: trollop
|
@@ -122,7 +122,7 @@ require_paths:
|
|
122
122
|
- lib
|
123
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
124
|
requirements:
|
125
|
-
- -
|
125
|
+
- - '>='
|
126
126
|
- !ruby/object:Gem::Version
|
127
127
|
version: 1.9.3
|
128
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|