utterson 0.1.1 → 0.1.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/spec/utterson_spec.rb +38 -28
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8d588f2917ca5d7bfdeb95bae81150afbf47930
4
- data.tar.gz: a38b9ea0380228eb434acf6bffac68a2c1b8d8ce
3
+ metadata.gz: 535d62e57f06b6f95ca5948cf2f235ff41e0dc05
4
+ data.tar.gz: 1e8098ec08f238c880596326d689d9272855793e
5
5
  SHA512:
6
- metadata.gz: ae2f3b547a9a7c1a602cd293d6e0a7eba83b8d8747671198635559793bf40d5363115eb6a873ac679729a14f939f16bfe94ad3a949fd0397c248c88c225f5819
7
- data.tar.gz: ede353e24c144ea04d6a8fd724ec37c449cc865bf84708ab05d83ad1a39a6f4f69ce0c34cb6e6f4e76586eeca9e1c2f4bf237d24c258401e5b8e006bb77fee62
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
 
@@ -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("http://example.com", "file.html")
41
- u.check_uri("http://example.com", "file.html")
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("https://example.com", "file.html")
47
- u.check_uri("https://example.com", "file.html")
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("//example.com", "file.html")
53
- u.check_uri("//example.com", "file.html")
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("../file.html", "file.html")
59
- u.check_uri("../file.html", "file.html")
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", "spec/fixtures/dir-structure/1.htm")
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
- u.check_local_uri("../sample_not_found.html", "spec/fixtures/dir-structure/1.htm")
73
- u.errors["spec/fixtures/dir-structure/1.htm"].should == {"../sample_not_found.html" => "File not found"}
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", root: "spec/fixtures")
78
- u2.check_local_uri("/sample.html", "spec/fixtures/dir-structure/1.htm")
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", "spec/fixtures/dir-structure/1.htm")
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", "spec/fixtures/dir-structure/1.htm")
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, "http://example.com/index.html").
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("http://example.com/index.html", "test.html")
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, "http://example.com/404.html").
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("http://example.com/404.html", "test.html")
118
+ u.check_remote_uri(url, html_file)
109
119
  puts u.errors.inspect
110
- u.errors["test.html"].should_not be_empty
111
- u.errors["test.html"]["http://example.com/404.html"].instance_of?(Net::HTTPNotFound).should be_true
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, "http://example.com/index.html").to_timeout
116
- u.check_remote_uri("http://example.com/index.html", "test.html")
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, "http://example.com/index.html").to_raise(Errno::ETIMEDOUT)
122
- u.check_remote_uri("http://example.com/index.html", "test.html")
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, "http://example.com/index.html").
137
+ stub_request(:head, url).
128
138
  to_raise(SocketError.new('getaddrinfo: Name or service not known'))
129
- u.check_remote_uri("http://example.com/index.html", "test.html")
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", "test.html")
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.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-03 00:00:00.000000000 Z
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