spec/integration_spec.rb in site_checker-0.3.0 vs spec/integration_spec.rb in site_checker-0.4.0

- old
+ new

@@ -27,11 +27,11 @@ it "should check the link to an external page" do content = "<html>text<a href=\"http://external.org/\"/></html>" webmock(@test_url, 200, content) webmock("http://external.org", 200, "") SiteChecker.check(@test_url, @root) - SiteChecker.remote_pages.should eql(["http://external.org/" ]) + SiteChecker.remote_pages.sort.should eql(["http://external.org/" ]) SiteChecker.problems.should be_empty end it "should not check the link to an external page if the reference checking is turned off" do SiteChecker.configure do |config| @@ -136,10 +136,18 @@ webmock(@test_url, 200, content) webmock("#{@root}/one-level-down", 404, "<html></html>") SiteChecker.check(@test_url, @root) SiteChecker.problems.should eql({@test_url => ["/one-level-down (404)"]}) end + + it "should report a problem when the content type is not an html" do + content = "<html>text<a href=\"/one-level-down\"/></html>" + webmock(@test_url, 200, content) + webmock("#{@root}/one-level-down", 200, "<html></html>", {"Content-Type"=>"text/plain; charset=UTF-8"}) + SiteChecker.check(@test_url, @root) + SiteChecker.problems.should eql({@test_url => ["/one-level-down (not a text/html content-type)"]}) + end end describe "file system based checking" do before(:each) do @root = fs_test_path @@ -150,11 +158,11 @@ @root = fs_test_path content = "<html>text<a href=\"/one-level-down\"/></html>" filesystemmock("index.html", content) filesystemmock("/one-level-down/index.html", content) SiteChecker.check(fs_test_path, @root) - SiteChecker.local_pages.should eql([fs_test_path, "/one-level-down"]) + SiteChecker.local_pages.sort.should eql(["/one-level-down", fs_test_path]) SiteChecker.problems.should be_empty end it "should report a problem when the local page cannot be found" do content = "<html>text<a href=\"/one-level-down\"/></html>" @@ -166,11 +174,11 @@ it "should use the local images" do content = "<html>text<img src=\"/a.png\"/></html>" filesystemmock("index.html", content) filesystemmock("a.png", "") SiteChecker.check(fs_test_path, @root) - SiteChecker.local_images.should eql(["/a.png"]) + SiteChecker.local_images.sort.should eql(["/a.png"]) SiteChecker.problems.should be_empty end it "should report a problem when the local image cannot be found" do content = "<html>text<img src=\"/a.png\"/></html>" @@ -197,10 +205,10 @@ it "should check the link to an external page" do content = "<html>text<a href=\"http://external.org/\"/></html>" webmock(@test_url, 200, content) webmock("http://external.org", 200, "") SiteChecker.check(@test_url) - SiteChecker.remote_pages.should eql(["http://external.org/" ]) + SiteChecker.remote_pages.sort.should eql(["http://external.org/" ]) SiteChecker.problems.should be_empty end it "should report a problem for a local page with absolute path" do content = "<html>text<a href=\"#{@test_url}/another\"/></html>"