site_checker 0.3.0 → 0.4.0

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.
data/History.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [v0.4.0](https://github.com/ZsoltFabok/site_checker/compare/v0.3.0...v0.4.0)
2
+ ### Fixes
3
+ * consider non-html content-type as an error (Zsolt Fabok, [issue 14](https://github.com/ZsoltFabok/site_checker/issues/14)})
4
+ * nokogiri 1.5.6 is out-dated, but in order to be compatible with ruby 1.8, I need it (Zsolt Fabok, [issue 15](https://github.com/ZsoltFabok/site_checker/issues/15))
5
+
1
6
  ## [v0.3.0](https://github.com/ZsoltFabok/site_checker/compare/v0.2.1...v0.3.0)
2
7
  ### Notes
3
8
  * the root argument is no longer mandatory (Zsolt Fabok)
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
- ###Site Checker [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/ZsoltFabok/site_checker) [![Build Status](https://travis-ci.org/ZsoltFabok/site_checker.png)](https://travis-ci.org/ZsoltFabok/site_checker) [![Dependency Status](https://gemnasium.com/ZsoltFabok/site_checker.png)](https://gemnasium.com/ZsoltFabok/site_checker)
1
+ ###Site Checker
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/site_checker.png)](http://badge.fury.io/rb/site_checker)
4
+ [![Build Status](https://travis-ci.org/ZsoltFabok/site_checker.png)](https://travis-ci.org/ZsoltFabok/site_checker)
5
+ [![Dependency Status](https://gemnasium.com/ZsoltFabok/site_checker.png)](https://gemnasium.com/ZsoltFabok/site_checker)
6
+ [![Code Climate](https://codeclimate.com/github/ZsoltFabok/site_checker.png)](https://codeclimate.com/github/ZsoltFabok/site_checker)
7
+ [![Coverage Status](https://coveralls.io/repos/ZsoltFabok/site_checker/badge.png)](https://coveralls.io/r/ZsoltFabok/site_checker)
3
8
 
4
9
  Site Checker is a simple ruby gem, which helps you check the integrity of your website by recursively visiting the referenced pages and images. I use it in my test environments to make sure that my websites don't have any dead links.
5
10
 
@@ -2,16 +2,19 @@ module SiteChecker
2
2
  module IO
3
3
  class ContentFromWeb
4
4
 
5
- def initialize(visit_references, root)
6
- @visit_references = visit_references
7
- @root = root
8
- end
5
+ def initialize(visit_references, root)
6
+ @visit_references = visit_references
7
+ @root = root
8
+ end
9
9
 
10
- def get(link)
10
+ def get(link)
11
11
  begin
12
12
  uri = create_absolute_reference(link.url)
13
13
  if link.local_page?
14
14
  content = open(uri)
15
+ if !content.meta['content-type'].start_with?('text/html')
16
+ raise "not a text/html content-type"
17
+ end
15
18
  elsif link.local_image?
16
19
  open(uri)
17
20
  elsif @visit_references
@@ -1,82 +1,82 @@
1
1
  module SiteChecker
2
- module Parse
3
- class Page
4
- def self.parse(content, ignore_list, root)
5
- links = []
6
- page = Nokogiri(content)
2
+ module Parse
3
+ class Page
4
+ def self.parse(content, ignore_list, root)
5
+ links = []
6
+ page = Nokogiri(content)
7
7
 
8
- links.concat(get_links(page, ignore_list, root))
9
- links.concat(get_images(page, ignore_list, root))
10
- links.concat(get_anchors(page))
11
- links.concat(local_pages_which_has_anchor_references(links, root))
8
+ links.concat(get_links(page, ignore_list, root))
9
+ links.concat(get_images(page, ignore_list, root))
10
+ links.concat(get_anchors(page))
11
+ links.concat(local_pages_which_has_anchor_references(links, root))
12
12
 
13
- links.uniq
14
- end
13
+ links.uniq
14
+ end
15
15
 
16
- private
17
- def self.get_links(page, ignore_list, root)
18
- links = []
19
- page.xpath("//a").reject {|a| ignored?(ignore_list, a['href'])}.each do |a|
20
- if a['href'].match(/(.*)#.+/) && !URI($1).absolute?
21
- kind = :anchor_ref
22
- else
23
- kind = :page
24
- end
25
- links << Link.create({:url => a['href'], :kind => kind})
26
- end
27
- set_location(links, root)
28
- end
16
+ private
17
+ def self.get_links(page, ignore_list, root)
18
+ links = []
19
+ page.xpath("//a").reject {|a| ignored?(ignore_list, a['href'])}.each do |a|
20
+ if a['href'].match(/(.*)#.+/) && !URI($1).absolute?
21
+ kind = :anchor_ref
22
+ else
23
+ kind = :page
24
+ end
25
+ links << Link.create({:url => a['href'], :kind => kind})
26
+ end
27
+ set_location(links, root)
28
+ end
29
29
 
30
- def self.get_images(page, ignore_list, root)
31
- links = []
32
- page.xpath("//img").reject {|img| ignored?(ignore_list, img['src'])}.each do |img|
33
- links << Link.create({:url => img['src'], :kind => :image})
34
- end
35
- set_location(links, root)
36
- end
30
+ def self.get_images(page, ignore_list, root)
31
+ links = []
32
+ page.xpath("//img").reject {|img| ignored?(ignore_list, img['src'])}.each do |img|
33
+ links << Link.create({:url => img['src'], :kind => :image})
34
+ end
35
+ set_location(links, root)
36
+ end
37
37
 
38
- def self.set_location(links, root)
39
- links.each do |link|
40
- uri = URI(link.url)
41
- if uri.to_s.start_with?(root)
42
- link.problem = "(absolute path)"
43
- link.location = :local
44
- else
45
- if uri.absolute?
46
- link.location = :remote
47
- else
48
- link.location = :local
49
- end
50
- end
51
- end
52
- end
38
+ def self.set_location(links, root)
39
+ links.each do |link|
40
+ uri = URI(link.url)
41
+ if uri.to_s.start_with?(root)
42
+ link.problem = "(absolute path)"
43
+ link.location = :local
44
+ else
45
+ if uri.absolute?
46
+ link.location = :remote
47
+ else
48
+ link.location = :local
49
+ end
50
+ end
51
+ end
52
+ end
53
53
 
54
- def self.ignored?(ignore_list, link)
55
- if link
56
- ignore_list.include? link
57
- else
58
- true
59
- end
60
- end
54
+ def self.ignored?(ignore_list, link)
55
+ if link
56
+ ignore_list.include? link
57
+ else
58
+ true
59
+ end
60
+ end
61
61
 
62
- def self.get_anchors(page)
63
- anchors = []
64
- page.xpath("//a").reject {|a| !a['id']}.each do |a|
65
- anchors << Link.create({:url => a['id'], :kind => :anchor})
66
- end
67
- anchors
68
- end
62
+ def self.get_anchors(page)
63
+ anchors = []
64
+ page.xpath("//a").reject {|a| !a['id']}.each do |a|
65
+ anchors << Link.create({:url => a['id'], :kind => :anchor})
66
+ end
67
+ anchors
68
+ end
69
69
 
70
- def self.local_pages_which_has_anchor_references(links, root)
71
- new_links = []
72
- links.find_all {|link| link.anchor_ref?}.each do |link|
73
- uri = URI(link.url)
74
- if link.url.match(/(.+)#/)
75
- new_links << Link.create({:url => $1, :kind => :page})
76
- end
77
- end
78
- set_location(new_links, root)
79
- end
80
- end
81
- end
70
+ def self.local_pages_which_has_anchor_references(links, root)
71
+ new_links = []
72
+ links.find_all {|link| link.anchor_ref?}.each do |link|
73
+ uri = URI(link.url)
74
+ if link.url.match(/(.+)#/)
75
+ new_links << Link.create({:url => $1, :kind => :page})
76
+ end
77
+ end
78
+ set_location(new_links, root)
79
+ end
80
+ end
81
+ end
82
82
  end
@@ -1,3 +1,3 @@
1
1
  module SiteChecker
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -8,7 +8,7 @@ require 'site_checker/version'
8
8
  Gem::Specification.new do |s|
9
9
  s.name = 'site_checker'
10
10
  s.version = SiteChecker::VERSION
11
- s.date = '2012-12-31'
11
+ s.date = '2013-08-31'
12
12
  s.summary = "site_checker-#{s.version}"
13
13
  s.description = "A simple tool for checking references on your website"
14
14
  s.authors = ["Zsolt Fabok"]
@@ -26,5 +26,9 @@ Gem::Specification.new do |s|
26
26
  s.add_development_dependency('rake' , '>= 10.0.3')
27
27
  s.add_development_dependency('yard' , '~> 0.8')
28
28
 
29
- s.add_runtime_dependency('nokogiri', '>= 1.5.6')
29
+ if RUBY_VERSION >= "1.9"
30
+ s.add_runtime_dependency('nokogiri', '~> 1.6.0')
31
+ else
32
+ s.add_runtime_dependency('nokogiri', '~> 1.5.6')
33
+ end
30
34
  end
@@ -29,7 +29,7 @@ describe "Integration" do
29
29
  webmock(@test_url, 200, content)
30
30
  webmock("http://external.org", 200, "")
31
31
  SiteChecker.check(@test_url, @root)
32
- SiteChecker.remote_pages.should eql(["http://external.org/" ])
32
+ SiteChecker.remote_pages.sort.should eql(["http://external.org/" ])
33
33
  SiteChecker.problems.should be_empty
34
34
  end
35
35
 
@@ -138,6 +138,14 @@ describe "Integration" do
138
138
  SiteChecker.check(@test_url, @root)
139
139
  SiteChecker.problems.should eql({@test_url => ["/one-level-down (404)"]})
140
140
  end
141
+
142
+ it "should report a problem when the content type is not an html" do
143
+ content = "<html>text<a href=\"/one-level-down\"/></html>"
144
+ webmock(@test_url, 200, content)
145
+ webmock("#{@root}/one-level-down", 200, "<html></html>", {"Content-Type"=>"text/plain; charset=UTF-8"})
146
+ SiteChecker.check(@test_url, @root)
147
+ SiteChecker.problems.should eql({@test_url => ["/one-level-down (not a text/html content-type)"]})
148
+ end
141
149
  end
142
150
 
143
151
  describe "file system based checking" do
@@ -152,7 +160,7 @@ describe "Integration" do
152
160
  filesystemmock("index.html", content)
153
161
  filesystemmock("/one-level-down/index.html", content)
154
162
  SiteChecker.check(fs_test_path, @root)
155
- SiteChecker.local_pages.should eql([fs_test_path, "/one-level-down"])
163
+ SiteChecker.local_pages.sort.should eql(["/one-level-down", fs_test_path])
156
164
  SiteChecker.problems.should be_empty
157
165
  end
158
166
 
@@ -168,7 +176,7 @@ describe "Integration" do
168
176
  filesystemmock("index.html", content)
169
177
  filesystemmock("a.png", "")
170
178
  SiteChecker.check(fs_test_path, @root)
171
- SiteChecker.local_images.should eql(["/a.png"])
179
+ SiteChecker.local_images.sort.should eql(["/a.png"])
172
180
  SiteChecker.problems.should be_empty
173
181
  end
174
182
 
@@ -199,7 +207,7 @@ describe "Integration" do
199
207
  webmock(@test_url, 200, content)
200
208
  webmock("http://external.org", 200, "")
201
209
  SiteChecker.check(@test_url)
202
- SiteChecker.remote_pages.should eql(["http://external.org/" ])
210
+ SiteChecker.remote_pages.sort.should eql(["http://external.org/" ])
203
211
  SiteChecker.problems.should be_empty
204
212
  end
205
213
 
@@ -5,21 +5,21 @@ module CliSpecHelper
5
5
  include IoSpecHelper
6
6
 
7
7
  def exec(command, arguments)
8
- stdin, stdout, stderr = Open3.popen3("#{command} #{arguments}")
9
- stdout.readlines.map {|line| line.chomp}.join("\n")
10
- end
8
+ stdin, stdout, stderr = Open3.popen3("#{command} #{arguments}")
9
+ stdout.readlines.map {|line| line.chomp}.join("\n")
10
+ end
11
11
 
12
- def option_list
13
- "Usage: site_checker [options] <site_url>\n" +
14
- " -e, --visit-external-references Visit external references (may take a bit longer)\n" +
15
- " -m, --max-recursion-depth N Set the depth of the recursion\n" +
16
- " -r, --root URL The root URL of the path\n" +
17
- " -i, --ignore URL Ignore the provided URL (can be applied several times)\n" +
18
- " -p, --print-local-pages Prints the list of the URLs of the collected local pages\n" +
19
- " -x, --print-remote-pages Prints the list of the URLs of the collected remote pages\n" +
20
- " -y, --print-local-images Prints the list of the URLs of the collected local images\n" +
21
- " -z, --print-remote-images Prints the list of the URLs of the collected remote images\n" +
22
- " -h, --help Show a short description and this message\n" +
23
- " -v, --version Show version\n"
24
- end
12
+ def option_list
13
+ "Usage: site_checker [options] <site_url>\n" +
14
+ " -e, --visit-external-references Visit external references (may take a bit longer)\n" +
15
+ " -m, --max-recursion-depth N Set the depth of the recursion\n" +
16
+ " -r, --root URL The root URL of the path\n" +
17
+ " -i, --ignore URL Ignore the provided URL (can be applied several times)\n" +
18
+ " -p, --print-local-pages Prints the list of the URLs of the collected local pages\n" +
19
+ " -x, --print-remote-pages Prints the list of the URLs of the collected remote pages\n" +
20
+ " -y, --print-local-images Prints the list of the URLs of the collected local images\n" +
21
+ " -z, --print-remote-images Prints the list of the URLs of the collected remote images\n" +
22
+ " -h, --help Show a short description and this message\n" +
23
+ " -v, --version Show version\n"
24
+ end
25
25
  end
@@ -2,45 +2,46 @@ require 'spec_helper'
2
2
  require_relative 'io_spec_helper'
3
3
 
4
4
  describe SiteChecker::IO::ContentFromWeb do
5
- include IoSpecHelper
6
- context "#get" do
7
- before(:each) do
8
- @root = "http://localhost:4000"
9
- @link = SiteChecker::Link.create({:url => "link", :kind => :page, :location => :local})
10
- @content = mock()
11
- @content_reader = SiteChecker::IO::ContentFromWeb.new(false, @root)
12
- end
5
+ include IoSpecHelper
6
+ context "#get" do
7
+ before(:each) do
8
+ @root = "http://localhost:4000"
9
+ @link = SiteChecker::Link.create({:url => "link", :kind => :page, :location => :local})
10
+ @content = mock()
11
+ @content_reader = SiteChecker::IO::ContentFromWeb.new(false, @root)
12
+ end
13
13
 
14
- it "should return the content of a link" do
14
+ it "should return the content of a link" do
15
+ @content.should_receive(:meta).and_return({"content-type"=>"text/html; charset=UTF-8"})
15
16
  @content_reader.should_receive(:open).with(URI("#{@root}/#{@link.url}")).and_return(@content)
16
17
  @content_reader.get(@link).should eql(@content)
17
- end
18
+ end
18
19
 
19
- it "should raise error if the link is broken" do
20
- @content_reader.should_receive(:open).with(URI("#{@root}/#{@link.url}")).
21
- and_raise(OpenURI::HTTPError.new("404 Not Found", nil))
20
+ it "should raise error if the link is broken" do
21
+ @content_reader.should_receive(:open).with(URI("#{@root}/#{@link.url}")).
22
+ and_raise(OpenURI::HTTPError.new("404 Not Found", nil))
22
23
  expect {@content_reader.get(@link)}.to raise_error(RuntimeError, "(404 Not Found)")
23
- end
24
+ end
24
25
 
25
- it "should check the existence of an image" do
26
- @link.kind = :image
27
- @link.url = "img/image1"
28
- @content_reader.should_receive(:open).with(URI("#{@root}/#{@link.url}"))
29
- @content_reader.get(@link)
30
- end
26
+ it "should check the existence of an image" do
27
+ @link.kind = :image
28
+ @link.url = "img/image1"
29
+ @content_reader.should_receive(:open).with(URI("#{@root}/#{@link.url}"))
30
+ @content_reader.get(@link)
31
+ end
31
32
 
32
- it "should not open a remote reference if opt-out" do
33
- @link.location = :remote
33
+ it "should not open a remote reference if opt-out" do
34
+ @link.location = :remote
34
35
  @content_reader.should_not_receive(:open).with(URI("#{@root}/#{@link.url}"))
35
36
  @content_reader.get(@link)
36
- end
37
+ end
37
38
 
38
- it "should open a remote reference if opt-in" do
39
- @content_reader = SiteChecker::IO::ContentFromWeb.new(true, @root)
40
- @link.location = :remote
41
- @link.url = "http://example.org"
39
+ it "should open a remote reference if opt-in" do
40
+ @content_reader = SiteChecker::IO::ContentFromWeb.new(true, @root)
41
+ @link.location = :remote
42
+ @link.url = "http://example.org"
42
43
  @content_reader.should_receive(:open).with(URI(@link.url))
43
44
  @content_reader.get(@link)
44
- end
45
- end
45
+ end
46
+ end
46
47
  end
@@ -1,8 +1,8 @@
1
1
  module IoSpecHelper
2
- def webmock(uri, status, content)
2
+ def webmock(uri, status, content, headers = {"Content-Type"=>"text/html; charset=UTF-8"})
3
3
  stub_request(:get, uri).
4
4
  with(:headers => {'Accept'=>'*/*'}).\
5
- to_return(:status => status, :body => content)
5
+ to_return(:status => status, :body => content, :headers => headers)
6
6
  end
7
7
 
8
8
  def filesystemmock(uri, content)
@@ -1,14 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SiteChecker::LinkCollector do
4
- context "#check" do
5
- before(:each) do
6
- @test_url = "http://localhost:4000"
7
- @root = "http://localhost:4000"
8
- @collector = SiteChecker::LinkCollector.new do |config|
9
- config.visit_references = true
10
- end
11
- end
4
+ context "#check" do
5
+ before(:each) do
6
+ @test_url = "http://localhost:4000"
7
+ @root = "http://localhost:4000"
8
+ @collector = SiteChecker::LinkCollector.new do |config|
9
+ config.visit_references = true
10
+ end
11
+ end
12
12
 
13
13
  it "should check a link only once" do
14
14
  content = "<html>text<a href=\"http://external.org/\"/><a href=\"http://external.org/\"/></html>"
@@ -37,5 +37,5 @@ describe SiteChecker::LinkCollector do
37
37
  @collector.check(@test_url, @root)
38
38
  @collector.problems.should be_empty
39
39
  end
40
- end
40
+ end
41
41
  end
@@ -1,94 +1,94 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe SiteChecker::Link do
4
- context "#create" do
5
- it "should create a link with attribute list" do
6
- link = SiteChecker::Link.create({:kind => :page, :location => "location"})
7
- link.kind.should eql(:page)
8
- link.location.should eql("location")
9
- end
10
- end
11
-
12
- context "#has_problem?" do
13
- it "should return true if there are no problem with the link" do
14
- SiteChecker::Link.create({}).has_problem?.should be_false
15
- end
16
-
17
- it "should return false if there are problems with the link" do
18
- SiteChecker::Link.create({:problem => "grr"}).has_problem?.should be_true
19
- end
20
- end
21
-
22
- context "#anchor?" do
23
- it "should return true for an anchor" do
24
- SiteChecker::Link.create({:kind => :anchor}).anchor?.should be_true
25
- end
26
-
27
- it "should return false for non anchor" do
28
- SiteChecker::Link.create({:kind => :page}).anchor?.should be_false
29
- end
30
- end
31
-
32
- context "#anchor_ref?" do
33
- it "should return true for an anchor_ref" do
34
- SiteChecker::Link.create({:kind => :anchor_ref}).anchor_ref?.should be_true
35
- end
36
-
37
- it "should return false for non anchor ref" do
38
- SiteChecker::Link.create({:kind => :page}).anchor_ref?.should be_false
39
- end
40
- end
41
-
42
- context "#anchor_related?" do
43
- it "should return true for an anchor_ref" do
44
- SiteChecker::Link.create({:kind => :anchor_ref}).anchor_related?.should be_true
45
- SiteChecker::Link.create({:kind => :anchor}).anchor_related?.should be_true
46
- end
47
-
48
- it "should return false for non anchor ref" do
49
- SiteChecker::Link.create({:kind => :page}).anchor_related?.should be_false
50
- end
51
- end
52
-
53
- context "#local_page?" do
54
- it "should return true if the page is local" do
55
- SiteChecker::Link.create({:kind => :page, :location => :local}).local_page?.should be_true
56
- end
57
-
58
- it "should return false if the page is local or not a page at all" do
59
- SiteChecker::Link.create({:kind => :page, :location => :remote}).local_page?.should be_false
60
- SiteChecker::Link.create({:kind => :image, :location => :local}).local_page?.should be_false
61
- end
62
- end
63
-
64
- context "#local_image?" do
65
- it "should return true if the image is local" do
66
- SiteChecker::Link.create({:kind => :image, :location => :local}).local_image?.should be_true
67
- end
68
-
69
- it "should return false if the image is local or not an image at all" do
70
- SiteChecker::Link.create({:kind => :image, :location => :remote}).local_image?.should be_false
71
- SiteChecker::Link.create({:kind => :page, :location => :local}).local_image?.should be_false
72
- end
73
- end
74
-
75
- context "#eql" do
76
- it "should return true if the urls are equal" do
77
- link1 = SiteChecker::Link.create({:url => "url"})
78
- link2 = SiteChecker::Link.create({:url => "url"})
79
- link1.should eql(link2)
80
- end
81
-
82
- it "should find the link in a collection" do
83
- link1 = SiteChecker::Link.create({:url => "url"})
84
- link2 = SiteChecker::Link.create({:url => "url"})
85
- [link1, link2].should include(link1)
86
- end
87
-
88
- it "should ignore trailing '/'" do
89
- link1 = SiteChecker::Link.create({:url => "/url"})
90
- link2 = SiteChecker::Link.create({:url => "url"})
91
- link1.should eql(link2)
92
- end
93
- end
4
+ context "#create" do
5
+ it "should create a link with attribute list" do
6
+ link = SiteChecker::Link.create({:kind => :page, :location => "location"})
7
+ link.kind.should eql(:page)
8
+ link.location.should eql("location")
9
+ end
10
+ end
11
+
12
+ context "#has_problem?" do
13
+ it "should return true if there are no problem with the link" do
14
+ SiteChecker::Link.create({}).has_problem?.should be_false
15
+ end
16
+
17
+ it "should return false if there are problems with the link" do
18
+ SiteChecker::Link.create({:problem => "grr"}).has_problem?.should be_true
19
+ end
20
+ end
21
+
22
+ context "#anchor?" do
23
+ it "should return true for an anchor" do
24
+ SiteChecker::Link.create({:kind => :anchor}).anchor?.should be_true
25
+ end
26
+
27
+ it "should return false for non anchor" do
28
+ SiteChecker::Link.create({:kind => :page}).anchor?.should be_false
29
+ end
30
+ end
31
+
32
+ context "#anchor_ref?" do
33
+ it "should return true for an anchor_ref" do
34
+ SiteChecker::Link.create({:kind => :anchor_ref}).anchor_ref?.should be_true
35
+ end
36
+
37
+ it "should return false for non anchor ref" do
38
+ SiteChecker::Link.create({:kind => :page}).anchor_ref?.should be_false
39
+ end
40
+ end
41
+
42
+ context "#anchor_related?" do
43
+ it "should return true for an anchor_ref" do
44
+ SiteChecker::Link.create({:kind => :anchor_ref}).anchor_related?.should be_true
45
+ SiteChecker::Link.create({:kind => :anchor}).anchor_related?.should be_true
46
+ end
47
+
48
+ it "should return false for non anchor ref" do
49
+ SiteChecker::Link.create({:kind => :page}).anchor_related?.should be_false
50
+ end
51
+ end
52
+
53
+ context "#local_page?" do
54
+ it "should return true if the page is local" do
55
+ SiteChecker::Link.create({:kind => :page, :location => :local}).local_page?.should be_true
56
+ end
57
+
58
+ it "should return false if the page is local or not a page at all" do
59
+ SiteChecker::Link.create({:kind => :page, :location => :remote}).local_page?.should be_false
60
+ SiteChecker::Link.create({:kind => :image, :location => :local}).local_page?.should be_false
61
+ end
62
+ end
63
+
64
+ context "#local_image?" do
65
+ it "should return true if the image is local" do
66
+ SiteChecker::Link.create({:kind => :image, :location => :local}).local_image?.should be_true
67
+ end
68
+
69
+ it "should return false if the image is local or not an image at all" do
70
+ SiteChecker::Link.create({:kind => :image, :location => :remote}).local_image?.should be_false
71
+ SiteChecker::Link.create({:kind => :page, :location => :local}).local_image?.should be_false
72
+ end
73
+ end
74
+
75
+ context "#eql" do
76
+ it "should return true if the urls are equal" do
77
+ link1 = SiteChecker::Link.create({:url => "url"})
78
+ link2 = SiteChecker::Link.create({:url => "url"})
79
+ link1.should eql(link2)
80
+ end
81
+
82
+ it "should find the link in a collection" do
83
+ link1 = SiteChecker::Link.create({:url => "url"})
84
+ link2 = SiteChecker::Link.create({:url => "url"})
85
+ [link1, link2].should include(link1)
86
+ end
87
+
88
+ it "should ignore trailing '/'" do
89
+ link1 = SiteChecker::Link.create({:url => "/url"})
90
+ link2 = SiteChecker::Link.create({:url => "url"})
91
+ link1.should eql(link2)
92
+ end
93
+ end
94
94
  end
@@ -8,6 +8,10 @@ rescue LoadError
8
8
  require "ruby-debug"
9
9
  end
10
10
 
11
+ # coveralls for github badge
12
+ require 'coveralls'
13
+ Coveralls.wear!
14
+
11
15
  require File.expand_path('../../lib/site_checker', __FILE__)
12
16
 
13
17
  # common
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-31 00:00:00.000000000 Z
12
+ date: 2013-08-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -80,17 +80,17 @@ dependencies:
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ! '>='
83
+ - - ~>
84
84
  - !ruby/object:Gem::Version
85
- version: 1.5.6
85
+ version: 1.6.0
86
86
  type: :runtime
87
87
  prerelease: false
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ! '>='
91
+ - - ~>
92
92
  - !ruby/object:Gem::Version
93
- version: 1.5.6
93
+ version: 1.6.0
94
94
  description: A simple tool for checking references on your website
95
95
  email: me@zsoltfabok.com
96
96
  executables:
@@ -144,7 +144,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  segments:
146
146
  - 0
147
- hash: -2225611601008227703
147
+ hash: 4215442512884695104
148
148
  required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
@@ -153,13 +153,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  segments:
155
155
  - 0
156
- hash: -2225611601008227703
156
+ hash: 4215442512884695104
157
157
  requirements: []
158
158
  rubyforge_project:
159
159
  rubygems_version: 1.8.23
160
160
  signing_key:
161
161
  specification_version: 3
162
- summary: site_checker-0.3.0
162
+ summary: site_checker-0.4.0
163
163
  test_files:
164
164
  - spec/dsl_spec.rb
165
165
  - spec/integration_spec.rb