w3clove 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  module W3Clove
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.2"
5
5
  end
@@ -1,3 +1,14 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Fri, 18 Nov 2011 21:46:46 GMT
4
+ Content-Type: text/html
5
+ Connection: keep-alive
6
+ Last-Modified: Mon, 14 Nov 2011 16:53:18 GMT
7
+ Content-Length: 4987
8
+ X-Varnish: 2000423390
9
+ Age: 0
10
+ Via: 1.1 varnish
11
+
1
12
  <html>
2
13
  <head>
3
14
  <title>Sample file with absolute links</title>
@@ -1,3 +1,13 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/0.7.67
3
+ Date: Fri, 18 Nov 2011 21:46:46 GMT
4
+ Content-Type: text/html
5
+ Connection: keep-alive
6
+ Last-Modified: Mon, 14 Nov 2011 16:53:18 GMT
7
+ Content-Length: 4987
8
+ X-Varnish: 2000423390
9
+ Age: 0
10
+ Via: 1.1 varnish
1
11
 
2
12
  <!DOCTYPE html>
3
13
  <html>
@@ -1,3 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/1.0.5
3
+ Date: Thu, 29 Dec 2011 23:10:13 GMT
4
+ Content-Type: text/html
5
+ Content-Length: 15013
6
+ Last-Modified: Fri, 02 Dec 2011 21:00:49 GMT
7
+ Connection: keep-alive
8
+ Accept-Ranges: bytes
9
+
1
10
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
11
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
12
 
@@ -118,7 +127,7 @@
118
127
  <div id="container">
119
128
  <div class="wrapper">
120
129
  <div id="mainCol">
121
-
130
+
122
131
 
123
132
 
124
133
  <h3>Start Here</h3>
@@ -222,7 +231,7 @@
222
231
  </dd>
223
232
  <dt><a href="api_documentation_guidelines.html">API Documentation Guidelines</a></dt><dd>
224
233
  <p>This guide documents the Ruby on Rails API documentation guidelines.</p>
225
- </dd>
234
+ </dd>
226
235
  <dt><a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a></dt><dd>
227
236
  <p>This guide documents the Ruby on Rails guides guidelines.</p>
228
237
  </dd></dl>
@@ -240,7 +249,7 @@
240
249
  <p>Release notes for Rails 2.2.</p>
241
250
  </dd></dl>
242
251
 
243
-
252
+
244
253
  <h3>Feedback</h3>
245
254
  <p>
246
255
  You're encouraged to help in keeping the quality of this guide.
@@ -0,0 +1,26 @@
1
+ HTTP/1.1 200 OK
2
+ Server: nginx/1.0.5
3
+ Date: Thu, 29 Dec 2011 23:10:13 GMT
4
+ Content-Type: text/html
5
+ Content-Length: 15013
6
+ Last-Modified: Fri, 02 Dec 2011 21:00:49 GMT
7
+ Connection: keep-alive
8
+ Accept-Ranges: bytes
9
+
10
+ <!DOCTYPE html>
11
+ <html>
12
+ <head>
13
+ <meta charset="utf-8" />
14
+ <title>Protocol-relative URLs</title>
15
+ </head>
16
+ <body>
17
+ <p>Internal links</p>
18
+ <a href="/">Internal: home page</a>
19
+ <a href="/faqs">Internal: FAQs</a>
20
+ <a href="//protocol-relative.com/contact">Internal: protocol-relative</a>
21
+
22
+ <p>External links</p>
23
+ <a href="http://google.com">External: normal link</a>
24
+ <a href="//yahoo.com">External: protocol-relative link</a>
25
+ </body>
26
+ </html>
@@ -1,3 +1,9 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Thu, 29 Dec 2011 23:08:54 GMT
3
+ Server: Apache/2.2.21 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.8e-fips-rhel5
4
+ Transfer-Encoding: chunked
5
+ Content-Type: text/xml
6
+
1
7
  <?xml version="1.0" encoding="UTF-8"?>
2
8
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3
9
  <url>
@@ -1,3 +1,12 @@
1
+ HTTP/1.1 200 OK
2
+ Date: Thu, 29 Dec 2011 23:10:49 GMT
3
+ Server: Apache
4
+ Last-Modified: Tue, 02 Aug 2011 17:06:13 GMT
5
+ ETag: "2b87a46-636-4a988c3d4eb40"
6
+ Accept-Ranges: bytes
7
+ Content-Length: 1590
8
+ Content-Type: text/html
9
+
1
10
  <!DOCTYPE html>
2
11
  <html>
3
12
  <head>
data/spec/sitemap_spec.rb CHANGED
@@ -4,17 +4,12 @@ require_relative 'spec_helper'
4
4
 
5
5
  describe W3Clove::Sitemap do
6
6
  before(:each) do
7
- @sitemap = W3Clove::Sitemap.new('http://ryanair.com/sitemap.xml')
8
- @sitemap.stub!(:doc).and_return(open("#{$samples_dir}/sitemap.xml"))
9
-
10
- @sitemap_html = W3Clove::Sitemap.new('http://guides.rubyonrails.org')
11
- @sitemap_html.stub!(:doc).and_return(open("#{$samples_dir}/guides.rubyonrails.org.html"))
12
-
13
- @sitemap_no_links = W3Clove::Sitemap.new('http://zigotica.com')
14
- @sitemap_no_links.stub!(:doc).and_return(open("#{$samples_dir}/zigotica.com.html"))
15
-
16
- @sitemap_with_trailing_slash = W3Clove::Sitemap.new('http://eparreno.com')
17
- @sitemap_with_trailing_slash.stub!(:doc).and_return(open("#{$samples_dir}/eparreno.com.html"))
7
+ @sitemap = W3Clove::Sitemap.new('http://ryanair.com/sitemap.xml')
8
+ @sitemap_html = W3Clove::Sitemap.new('http://guides.rubyonrails.org')
9
+ @sitemap_no_links = W3Clove::Sitemap.new('http://zigotica.com')
10
+ @sitemap_with_trailing_slash = W3Clove::Sitemap.new('http://eparreno.com')
11
+ @sitemap_with_protocol_relative = W3Clove::Sitemap.new('http://protocol-relative.com')
12
+ @sitemap_with_protocol_relative_https = W3Clove::Sitemap.new('https://protocol-relative.com')
18
13
 
19
14
  MarkupValidator.any_instance.stubs(:validate_uri).returns(stubbed_validator_results)
20
15
  end
@@ -32,42 +27,41 @@ describe W3Clove::Sitemap do
32
27
  end
33
28
 
34
29
  it "should get pages from the sample guides.rubyonrails.org site" do
35
- @sitemap_html.pages.length.should == 34
36
- @sitemap_html.pages.map {|p| p.url}.should == [
37
- "http://guides.rubyonrails.org/index.html",
38
- "http://guides.rubyonrails.org/",
39
- "http://guides.rubyonrails.org/getting_started.html",
40
- "http://guides.rubyonrails.org/migrations.html",
41
- "http://guides.rubyonrails.org/active_record_validations_callbacks.html",
42
- "http://guides.rubyonrails.org/association_basics.html",
43
- "http://guides.rubyonrails.org/active_record_querying.html",
44
- "http://guides.rubyonrails.org/layouts_and_rendering.html",
45
- "http://guides.rubyonrails.org/form_helpers.html",
46
- "http://guides.rubyonrails.org/action_controller_overview.html",
47
- "http://guides.rubyonrails.org/routing.html",
48
- "http://guides.rubyonrails.org/active_support_core_extensions.html",
49
- "http://guides.rubyonrails.org/i18n.html",
50
- "http://guides.rubyonrails.org/action_mailer_basics.html",
51
- "http://guides.rubyonrails.org/testing.html",
52
- "http://guides.rubyonrails.org/security.html",
53
- "http://guides.rubyonrails.org/debugging_rails_applications.html",
54
- "http://guides.rubyonrails.org/performance_testing.html",
55
- "http://guides.rubyonrails.org/configuring.html",
56
- "http://guides.rubyonrails.org/command_line.html",
57
- "http://guides.rubyonrails.org/caching_with_rails.html",
58
- "http://guides.rubyonrails.org/asset_pipeline.html",
59
- "http://guides.rubyonrails.org/plugins.html",
60
- "http://guides.rubyonrails.org/rails_on_rack.html",
61
- "http://guides.rubyonrails.org/generators.html",
62
- "http://guides.rubyonrails.org/contributing_to_ruby_on_rails.html",
63
- "http://guides.rubyonrails.org/api_documentation_guidelines.html",
64
- "http://guides.rubyonrails.org/ruby_on_rails_guides_guidelines.html",
65
- "http://guides.rubyonrails.org/3_1_release_notes.html",
66
- "http://guides.rubyonrails.org/3_0_release_notes.html",
67
- "http://guides.rubyonrails.org/2_3_release_notes.html",
68
- "http://guides.rubyonrails.org/2_2_release_notes.html",
69
- "http://guides.rubyonrails.org/credits.html",
70
- "http://guides.rubyonrails.org/v2.3.11/" ]
30
+ @sitemap_html.pages.length.should == 33
31
+ @sitemap_html.pages.map {|p| p.url}
32
+ .should == ["http://guides.rubyonrails.org/index.html",
33
+ "http://guides.rubyonrails.org/",
34
+ "http://guides.rubyonrails.org/getting_started.html",
35
+ "http://guides.rubyonrails.org/migrations.html",
36
+ "http://guides.rubyonrails.org/active_record_validations_callbacks.html",
37
+ "http://guides.rubyonrails.org/association_basics.html",
38
+ "http://guides.rubyonrails.org/active_record_querying.html",
39
+ "http://guides.rubyonrails.org/layouts_and_rendering.html",
40
+ "http://guides.rubyonrails.org/form_helpers.html",
41
+ "http://guides.rubyonrails.org/action_controller_overview.html",
42
+ "http://guides.rubyonrails.org/routing.html",
43
+ "http://guides.rubyonrails.org/active_support_core_extensions.html",
44
+ "http://guides.rubyonrails.org/i18n.html",
45
+ "http://guides.rubyonrails.org/action_mailer_basics.html",
46
+ "http://guides.rubyonrails.org/testing.html",
47
+ "http://guides.rubyonrails.org/security.html",
48
+ "http://guides.rubyonrails.org/debugging_rails_applications.html",
49
+ "http://guides.rubyonrails.org/performance_testing.html",
50
+ "http://guides.rubyonrails.org/configuring.html",
51
+ "http://guides.rubyonrails.org/command_line.html",
52
+ "http://guides.rubyonrails.org/caching_with_rails.html",
53
+ "http://guides.rubyonrails.org/plugins.html",
54
+ "http://guides.rubyonrails.org/rails_on_rack.html",
55
+ "http://guides.rubyonrails.org/generators.html",
56
+ "http://guides.rubyonrails.org/contributing_to_ruby_on_rails.html",
57
+ "http://guides.rubyonrails.org/api_documentation_guidelines.html",
58
+ "http://guides.rubyonrails.org/ruby_on_rails_guides_guidelines.html",
59
+ "http://guides.rubyonrails.org/3_0_release_notes.html",
60
+ "http://guides.rubyonrails.org/2_3_release_notes.html",
61
+ "http://guides.rubyonrails.org/2_2_release_notes.html",
62
+ "http://guides.rubyonrails.org/contribute.html",
63
+ "http://guides.rubyonrails.org/credits.html",
64
+ "http://guides.rubyonrails.org/v2.3.8/"]
71
65
  end
72
66
 
73
67
  it "should include sitemap url at least, even if no links were found" do
@@ -80,6 +74,27 @@ describe W3Clove::Sitemap do
80
74
  urls.should include 'http://eparreno.com/'
81
75
  urls.should_not include 'http://eparreno.com'
82
76
  end
77
+
78
+ context "protocol-relative links" do
79
+ it "should include only internal links" do
80
+ @sitemap_with_protocol_relative.pages.size.should == 3
81
+ @sitemap_with_protocol_relative.pages.map {|p| p.url}.sort.should == ['http://protocol-relative.com/',
82
+ 'http://protocol-relative.com/contact',
83
+ 'http://protocol-relative.com/faqs']
84
+ end
85
+
86
+ it "should include protocol-relative link to same domain" do
87
+ @sitemap_with_protocol_relative.pages.map {|p| p.url}.should include 'http://protocol-relative.com/contact'
88
+ end
89
+
90
+ it "should have the same protocol than the root url" do
91
+ @sitemap_with_protocol_relative_https.pages.map {|p| p.url}.should include 'https://protocol-relative.com/contact'
92
+ end
93
+
94
+ it "should not include protocol-relative link to another domain" do
95
+ @sitemap_with_protocol_relative.pages.map {|p| p.url}.should_not include 'http://yahoo.com'
96
+ end
97
+ end
83
98
  end
84
99
 
85
100
  describe "validations" do
data/spec/spec_helper.rb CHANGED
@@ -3,8 +3,16 @@
3
3
  require_relative '../lib/w3clove'
4
4
  require_relative './mocks/mocked_validator'
5
5
  require 'mocha'
6
+ require 'fakeweb'
6
7
 
7
8
  $samples_dir = File.dirname(__FILE__) + '/samples'
9
+ FakeWeb.register_uri(:get, "http://ryanair.com/sitemap.xml", :response => open("#{$samples_dir}/sitemap.xml").read)
10
+ FakeWeb.register_uri(:get, "http://guides.rubyonrails.org", :response => open("#{$samples_dir}/guides.rubyonrails.org.html").read)
11
+ FakeWeb.register_uri(:get, "http://eparreno.com", :response => open("#{$samples_dir}/eparreno.com.html").read)
12
+ FakeWeb.register_uri(:get, "http://www.eparreno.com", :response => open("#{$samples_dir}/eparreno.com.html").read)
13
+ FakeWeb.register_uri(:get, "http://zigotica.com", :response => open("#{$samples_dir}/zigotica.com.html").read)
14
+ FakeWeb.register_uri(:get, "http://protocol-relative.com", :response => open("#{$samples_dir}/protocol_relative.html").read)
15
+ FakeWeb.register_uri(:get, "https://protocol-relative.com", :response => open("#{$samples_dir}/protocol_relative.html").read)
8
16
 
9
17
  def message_text(message_id)
10
18
  message_texts = {
data/w3clove.gemspec CHANGED
@@ -18,9 +18,10 @@ and outputs a detailed report with all errors and warnings}
18
18
 
19
19
  gem.add_dependency 'w3c_validators', '~> 1.0.2'
20
20
  gem.add_dependency 'nokogiri', '~> 1.5.0'
21
- gem.add_dependency 'metainspector', '~> 1.8.7'
21
+ gem.add_dependency 'metainspector', '~> 1.8.8'
22
22
 
23
23
  gem.add_development_dependency 'rspec', '~> 2.5.0'
24
24
  gem.add_development_dependency 'mocha', '~> 0.9.12'
25
25
  gem.add_development_dependency 'rake', '~> 0.9.2'
26
+ gem.add_development_dependency 'fakeweb', '~> 1.3.0'
26
27
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: w3clove
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 1
10
- version: 0.6.1
9
+ - 2
10
+ version: 0.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jaime Iniesta
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-16 00:00:00 Z
18
+ date: 2011-12-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: w3c_validators
@@ -57,12 +57,12 @@ dependencies:
57
57
  requirements:
58
58
  - - ~>
59
59
  - !ruby/object:Gem::Version
60
- hash: 57
60
+ hash: 39
61
61
  segments:
62
62
  - 1
63
63
  - 8
64
- - 7
65
- version: 1.8.7
64
+ - 8
65
+ version: 1.8.8
66
66
  type: :runtime
67
67
  version_requirements: *id003
68
68
  - !ruby/object:Gem::Dependency
@@ -113,6 +113,22 @@ dependencies:
113
113
  version: 0.9.2
114
114
  type: :development
115
115
  version_requirements: *id006
116
+ - !ruby/object:Gem::Dependency
117
+ name: fakeweb
118
+ prerelease: false
119
+ requirement: &id007 !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ~>
123
+ - !ruby/object:Gem::Version
124
+ hash: 27
125
+ segments:
126
+ - 1
127
+ - 3
128
+ - 0
129
+ version: 1.3.0
130
+ type: :development
131
+ version_requirements: *id007
116
132
  description: |-
117
133
  this tool allows you to check the markup validation of a whole site,
118
134
  and outputs a detailed report with all errors and warnings
@@ -147,6 +163,7 @@ files:
147
163
  - spec/samples/absolute_links.html
148
164
  - spec/samples/eparreno.com.html
149
165
  - spec/samples/guides.rubyonrails.org.html
166
+ - spec/samples/protocol_relative.html
150
167
  - spec/samples/sitemap.xml
151
168
  - spec/samples/zigotica.com.html
152
169
  - spec/sitemap_spec.rb