spec/sitemap_spec.rb in w3clove-0.7.3 vs spec/sitemap_spec.rb in w3clove-0.7.4
- old
+ new
@@ -9,10 +9,11 @@
@sitemap_no_links = W3Clove::Sitemap.new('http://zigotica.com')
@sitemap_with_trailing_slash = W3Clove::Sitemap.new('http://eparreno.com')
@sitemap_with_protocol_relative = W3Clove::Sitemap.new('http://protocol-relative.com')
@sitemap_with_protocol_relative_https = W3Clove::Sitemap.new('https://protocol-relative.com')
@sitemap_for_exclusions = W3Clove::Sitemap.new('http://example.com/exclusions')
+ @sitemap_for_absolute_urls = W3Clove::Sitemap.new('http://w3clove.com/faqs')
MarkupValidator.any_instance.stubs(:validate_uri).returns(stubbed_validator_results)
end
it "should have an URL" do
@@ -26,14 +27,14 @@
@sitemap.pages[1].url.should == 'http://www.ryanair.com/es/careers/job'
@sitemap.pages[2].url.should == 'http://www.ryanair.com/es/about'
end
it "should get pages from the sample guides.rubyonrails.org site" do
- @sitemap_html.pages.length.should == 33
+ #@sitemap_html.pages.length.should == 34
@sitemap_html.pages.map {|p| p.url}
- .should == ["http://guides.rubyonrails.org/index.html",
- "http://guides.rubyonrails.org/",
+ .should == ["http://guides.rubyonrails.org",
+ "http://guides.rubyonrails.org/index.html",
"http://guides.rubyonrails.org/getting_started.html",
"http://guides.rubyonrails.org/migrations.html",
"http://guides.rubyonrails.org/active_record_validations_callbacks.html",
"http://guides.rubyonrails.org/association_basics.html",
"http://guides.rubyonrails.org/active_record_querying.html",
@@ -63,30 +64,51 @@
"http://guides.rubyonrails.org/contribute.html",
"http://guides.rubyonrails.org/credits.html",
"http://guides.rubyonrails.org/v2.3.8/"]
end
+ it "should get correct absolute links for internal pages" do
+ @sitemap_for_absolute_urls.pages.length.should == 9
+ @sitemap_for_absolute_urls.pages.map {|p| p.url}
+ .should == ["http://w3clove.com/faqs",
+ "http://w3clove.com/",
+ "http://w3clove.com/plans-and-pricing",
+ "http://w3clove.com/contact",
+ "http://w3clove.com/charts/errors",
+ "http://w3clove.com/credits",
+ "http://w3clove.com/signin",
+ "http://w3clove.com/api_v1_reference",
+ "http://w3clove.com/terms_of_service"]
+ end
+
it "should include sitemap url at least, even if no links were found" do
@sitemap_no_links.pages.length.should == 1
@sitemap_no_links.pages[0].url.should == 'http://zigotica.com'
end
- it "should not repeat URLs with and without trailing slash" do
+ it "should not repeat sitemap URL with and without trailing slash" do
urls = @sitemap_with_trailing_slash.pages.collect(&:url)
- urls.should include 'http://eparreno.com/'
- urls.should_not include 'http://eparreno.com'
+ urls.should include 'http://eparreno.com'
+ urls.should_not include 'http://eparreno.com/'
end
+ it "should not repeat internal URLs with and without trailing slash" do
+ urls = @sitemap_for_absolute_urls.pages.collect(&:url)
+ urls.should include 'http://w3clove.com/faqs'
+ urls.should_not include 'http://w3clove.com/faqs/'
+ end
+
it "should exclude non-html pages" do
- @sitemap_for_exclusions.pages.length.should == 2
- @sitemap_for_exclusions.pages.first.url.should == 'http://example.com/exclusions/'
- @sitemap_for_exclusions.pages.last.url.should == 'http://example.com/exclusions/faqs'
+ @sitemap_for_exclusions.pages.length.should == 3
+ @sitemap_for_exclusions.pages[0].url.should == 'http://example.com/exclusions'
+ @sitemap_for_exclusions.pages[1].url.should == 'http://example.com/'
+ @sitemap_for_exclusions.pages[2].url.should == 'http://example.com/faqs'
end
context "protocol-relative links" do
it "should include only internal links" do
@sitemap_with_protocol_relative.pages.size.should == 3
- @sitemap_with_protocol_relative.pages.map {|p| p.url}.sort.should == ['http://protocol-relative.com/',
+ @sitemap_with_protocol_relative.pages.map {|p| p.url}.sort.should == ['http://protocol-relative.com',
'http://protocol-relative.com/contact',
'http://protocol-relative.com/faqs']
end
it "should include protocol-relative link to same domain" do
\ No newline at end of file