html-proofer 2.5.1 → 2.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/htmlproof +11 -1
- data/lib/html/proofer.rb +1 -0
- data/lib/html/proofer/check_runner.rb +1 -1
- data/lib/html/proofer/checkable.rb +2 -2
- data/lib/html/proofer/checks/links.rb +2 -0
- data/lib/html/proofer/url_validator.rb +14 -3
- data/lib/html/proofer/version.rb +1 -1
- metadata +4 -344
- data/.gitignore +0 -26
- data/.travis.yml +0 -14
- data/Gemfile +0 -3
- data/LICENSE.txt +0 -22
- data/README.md +0 -276
- data/Rakefile +0 -21
- data/html-proofer.gemspec +0 -32
- data/script/bootstrap +0 -5
- data/spec/html/proofer/checkable_spec.rb +0 -47
- data/spec/html/proofer/command_spec.rb +0 -88
- data/spec/html/proofer/favicon_spec.rb +0 -47
- data/spec/html/proofer/fixtures/favicon/favicon_absent.html +0 -4
- data/spec/html/proofer/fixtures/favicon/favicon_absent_apple.html +0 -7
- data/spec/html/proofer/fixtures/favicon/favicon_broken.html +0 -7
- data/spec/html/proofer/fixtures/favicon/favicon_broken_but_ignored.html +0 -7
- data/spec/html/proofer/fixtures/favicon/favicon_present.html +0 -7
- data/spec/html/proofer/fixtures/favicon/favicon_present_shortcut.html +0 -7
- data/spec/html/proofer/fixtures/html/div_inside_head.html +0 -6
- data/spec/html/proofer/fixtures/html/html5_tags.html +0 -9
- data/spec/html/proofer/fixtures/html/ignore_script_embeds.html +0 -3
- data/spec/html/proofer/fixtures/html/invalid_tag.html +0 -3
- data/spec/html/proofer/fixtures/html/missing_closing_quotes.html +0 -5
- data/spec/html/proofer/fixtures/html/opening_and_ending_tag_mismatch.html +0 -7
- data/spec/html/proofer/fixtures/html/svg_elements.html +0 -729
- data/spec/html/proofer/fixtures/html/unescaped_ampersand_in_attribute.html +0 -4
- data/spec/html/proofer/fixtures/html/unmatched_end_tag.html +0 -5
- data/spec/html/proofer/fixtures/images/emptyImageAltText.html +0 -10
- data/spec/html/proofer/fixtures/images/existingImageExternal.html +0 -9
- data/spec/html/proofer/fixtures/images/gpl.png +0 -0
- data/spec/html/proofer/fixtures/images/ignorableAltViaOptions.html +0 -13
- data/spec/html/proofer/fixtures/images/ignorableImages.html +0 -10
- data/spec/html/proofer/fixtures/images/ignoreAltButNotLink.html +0 -13
- data/spec/html/proofer/fixtures/images/image_missing_protocol_invalid.html +0 -9
- data/spec/html/proofer/fixtures/images/image_missing_protocol_valid.html +0 -9
- data/spec/html/proofer/fixtures/images/missingImageAlt.html +0 -9
- data/spec/html/proofer/fixtures/images/missingImageAltText.html +0 -9
- data/spec/html/proofer/fixtures/images/missingImageExternal.html +0 -9
- data/spec/html/proofer/fixtures/images/missingImageInternal.html +0 -9
- data/spec/html/proofer/fixtures/images/missingImageSrc.html +0 -9
- data/spec/html/proofer/fixtures/images/relativeToSelf.html +0 -2
- data/spec/html/proofer/fixtures/images/rootRelativeImages.html +0 -2
- data/spec/html/proofer/fixtures/images/srcSetCheck.html +0 -7
- data/spec/html/proofer/fixtures/images/srcSetIgnorable.html +0 -13
- data/spec/html/proofer/fixtures/images/srcSetMissingAlt.html +0 -7
- data/spec/html/proofer/fixtures/images/srcSetMissingImage.html +0 -7
- data/spec/html/proofer/fixtures/images/terribleImageName.html +0 -9
- data/spec/html/proofer/fixtures/images/workingDataURIImage.html +0 -3
- data/spec/html/proofer/fixtures/links/_site/folder.html/index.html +0 -1
- data/spec/html/proofer/fixtures/links/anchors_in_pre.html +0 -12
- data/spec/html/proofer/fixtures/links/attributeWithDash.html +0 -8
- data/spec/html/proofer/fixtures/links/blank_mailto_link.html +0 -9
- data/spec/html/proofer/fixtures/links/blank_tel_link.html +0 -9
- data/spec/html/proofer/fixtures/links/brokenHashExternal.html +0 -11
- data/spec/html/proofer/fixtures/links/brokenHashInternal.html +0 -14
- data/spec/html/proofer/fixtures/links/brokenHashOnTheWeb.html +0 -2
- data/spec/html/proofer/fixtures/links/brokenInternalLink.html +0 -0
- data/spec/html/proofer/fixtures/links/brokenLinkExternal.html +0 -11
- data/spec/html/proofer/fixtures/links/brokenLinkInternal.html +0 -10
- data/spec/html/proofer/fixtures/links/brokenLinkWithNumber.html +0 -8
- data/spec/html/proofer/fixtures/links/brokenUnixLinks.html +0 -5
- data/spec/html/proofer/fixtures/links/broken_hash_with_query.html +0 -9
- data/spec/html/proofer/fixtures/links/checkSSLLinks.html +0 -1
- data/spec/html/proofer/fixtures/links/check_just_once.html +0 -8
- data/spec/html/proofer/fixtures/links/ensure_typhoeus_options.html +0 -1
- data/spec/html/proofer/fixtures/links/erstiebegr%C3%BC%C3%9Fung.html +0 -0
- data/spec/html/proofer/fixtures/links/erstiebegr/303/274/303/237ung.html +0 -0
- data/spec/html/proofer/fixtures/links/escape_pipes.html +0 -9
- data/spec/html/proofer/fixtures/links/file.foo +0 -11
- data/spec/html/proofer/fixtures/links/folder-php/index.php +0 -2
- data/spec/html/proofer/fixtures/links/folder/anchorLink.html +0 -0
- data/spec/html/proofer/fixtures/links/folder/assets/barrel.png +0 -0
- data/spec/html/proofer/fixtures/links/folder/index.html +0 -0
- data/spec/html/proofer/fixtures/links/folder/multiples/catalog/file.html +0 -8
- data/spec/html/proofer/fixtures/links/folder/multiples/javadoc/file.html +0 -8
- data/spec/html/proofer/fixtures/links/folder/relativeImage.html +0 -2
- data/spec/html/proofer/fixtures/links/githubHash.html +0 -1
- data/spec/html/proofer/fixtures/links/gpl.png +0 -0
- data/spec/html/proofer/fixtures/links/hashReferringToSelf.html +0 -44
- data/spec/html/proofer/fixtures/links/head_link_href.html +0 -7
- data/spec/html/proofer/fixtures/links/head_link_href_absent.html +0 -7
- data/spec/html/proofer/fixtures/links/head_link_href_empty.html +0 -7
- data/spec/html/proofer/fixtures/links/ignorableLinks.html +0 -13
- data/spec/html/proofer/fixtures/links/ignorableLinksViaOptions.html +0 -13
- data/spec/html/proofer/fixtures/links/ignores_cases.html +0 -3
- data/spec/html/proofer/fixtures/links/invalid_mailto_link.html +0 -9
- data/spec/html/proofer/fixtures/links/javascript_link.html +0 -9
- data/spec/html/proofer/fixtures/links/linkToFolder.html +0 -9
- data/spec/html/proofer/fixtures/links/linkTranslatedViaHrefSwap.html +0 -9
- data/spec/html/proofer/fixtures/links/linkWithHttps.html +0 -9
- data/spec/html/proofer/fixtures/links/linkWithRedirect.html +0 -14
- data/spec/html/proofer/fixtures/links/link_directory_without_slash.html +0 -1
- data/spec/html/proofer/fixtures/links/link_missing_protocol_invalid.html +0 -9
- data/spec/html/proofer/fixtures/links/link_missing_protocol_valid.html +0 -9
- data/spec/html/proofer/fixtures/links/link_pointing_to_directory.html +0 -1
- data/spec/html/proofer/fixtures/links/links_in_pre.html +0 -13
- data/spec/html/proofer/fixtures/links/mailto_link.html +0 -9
- data/spec/html/proofer/fixtures/links/missingLinkHref.html +0 -9
- data/spec/html/proofer/fixtures/links/multipleProblems.html +0 -11
- data/spec/html/proofer/fixtures/links/nodupe.html +0 -1
- data/spec/html/proofer/fixtures/links/non_standard_characters.html +0 -10
- data/spec/html/proofer/fixtures/links/notarealhash.html +0 -0
- data/spec/html/proofer/fixtures/links/other_protocols.html +0 -4
- data/spec/html/proofer/fixtures/links/placeholder_with_empty_id.html +0 -1
- data/spec/html/proofer/fixtures/links/placeholder_with_id.html +0 -1
- data/spec/html/proofer/fixtures/links/placeholder_with_name.html +0 -1
- data/spec/html/proofer/fixtures/links/redirected_error.html +0 -1
- data/spec/html/proofer/fixtures/links/relativeLinks.html +0 -4
- data/spec/html/proofer/fixtures/links/rootLink/folder/index.html +0 -1
- data/spec/html/proofer/fixtures/links/rootLink/index.html +0 -1
- data/spec/html/proofer/fixtures/links/rootLink/rootLink.html +0 -9
- data/spec/html/proofer/fixtures/links/tel_link.html +0 -9
- data/spec/html/proofer/fixtures/links/urlencoded-href.html +0 -2
- data/spec/html/proofer/fixtures/links/utf8Link.html +0 -2
- data/spec/html/proofer/fixtures/resources/Screen Shot 2012-08-09 at 7.51.18 AM.png +0 -0
- data/spec/html/proofer/fixtures/resources/books/assets/getting-good-with-git.jpg +0 -0
- data/spec/html/proofer/fixtures/resources/books/assets/pro-git.jpg +0 -0
- data/spec/html/proofer/fixtures/resources/books/assets/version-control-with-git.jpg +0 -0
- data/spec/html/proofer/fixtures/resources/books/nestedRelativeImages.html +0 -5
- data/spec/html/proofer/fixtures/resources/gpl.png +0 -0
- data/spec/html/proofer/fixtures/scripts/ignorableLinksViaOptions.html +0 -4
- data/spec/html/proofer/fixtures/scripts/script.js +0 -1
- data/spec/html/proofer/fixtures/scripts/script_broken_external.html +0 -9
- data/spec/html/proofer/fixtures/scripts/script_content.html +0 -9
- data/spec/html/proofer/fixtures/scripts/script_content_absent.html +0 -9
- data/spec/html/proofer/fixtures/scripts/script_in_pre.html +0 -5
- data/spec/html/proofer/fixtures/scripts/script_missing_internal.html +0 -9
- data/spec/html/proofer/fixtures/scripts/script_valid_internal.html +0 -9
- data/spec/html/proofer/fixtures/sorting/issue/broken_image_one.html +0 -1
- data/spec/html/proofer/fixtures/sorting/issue/broken_image_two.html +0 -4
- data/spec/html/proofer/fixtures/sorting/path/multiple_issues.html +0 -11
- data/spec/html/proofer/fixtures/sorting/path/single_issue.html +0 -1
- data/spec/html/proofer/fixtures/sorting/status/a_404.html +0 -1
- data/spec/html/proofer/fixtures/sorting/status/broken_link.html +0 -3
- data/spec/html/proofer/fixtures/sorting/status/missing_redirect.html +0 -1
- data/spec/html/proofer/fixtures/utils/lang-jp.html +0 -1
- data/spec/html/proofer/fixtures/vcr_cassettes/images/existingImageExternal_html.yml +0 -62
- data/spec/html/proofer/fixtures/vcr_cassettes/images/ignoreAltButNotLink_html_alt_ignore_/_/_.yml +0 -45
- data/spec/html/proofer/fixtures/vcr_cassettes/images/image_missing_protocol_invalid_html.yml +0 -117
- data/spec/html/proofer/fixtures/vcr_cassettes/images/image_missing_protocol_valid_html.yml +0 -62
- data/spec/html/proofer/fixtures/vcr_cassettes/images/missingImageExternal_html.yml +0 -45
- data/spec/html/proofer/fixtures/vcr_cassettes/links/attributeWithDash_html.yml +0 -73
- data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenHashOnTheWeb_html.yml +0 -56
- data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenHashOnTheWeb_html_check_external_hash_true_.yml +0 -719
- data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenHashOnTheWeb_html_only_4xx_true_.yml +0 -56
- data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenLinkExternal_html.yml +0 -96
- data/spec/html/proofer/fixtures/vcr_cassettes/links/brokenUnixLinks_html.yml +0 -156
- data/spec/html/proofer/fixtures/vcr_cassettes/links/checkSSLLinks_html.yml +0 -50
- data/spec/html/proofer/fixtures/vcr_cassettes/links/check_just_once_html.yml +0 -87
- data/spec/html/proofer/fixtures/vcr_cassettes/links/ensure_typhoeus_options_html_typhoeus_ssl_verifypeer_false_.yml +0 -40
- data/spec/html/proofer/fixtures/vcr_cassettes/links/escape_pipes_html.yml +0 -52
- data/spec/html/proofer/fixtures/vcr_cassettes/links/file_foo_ext_foo_.yml +0 -96
- data/spec/html/proofer/fixtures/vcr_cassettes/links/githubHash_html.yml +0 -73
- data/spec/html/proofer/fixtures/vcr_cassettes/links/linkWithHttps_html.yml +0 -73
- data/spec/html/proofer/fixtures/vcr_cassettes/links/linkWithRedirect_html.yml +0 -236
- data/spec/html/proofer/fixtures/vcr_cassettes/links/linkWithRedirect_html_only_4xx_true_typhoeus_followlocation_false_.yml +0 -318
- data/spec/html/proofer/fixtures/vcr_cassettes/links/linkWithRedirect_html_typhoeus_followlocation_false_.yml +0 -318
- data/spec/html/proofer/fixtures/vcr_cassettes/links/link_missing_protocol_invalid_html.yml +0 -45
- data/spec/html/proofer/fixtures/vcr_cassettes/links/link_missing_protocol_valid_html.yml +0 -73
- data/spec/html/proofer/fixtures/vcr_cassettes/links/nodupe_html.yml +0 -182
- data/spec/html/proofer/fixtures/vcr_cassettes/links/non_standard_characters_html.yml +0 -113
- data/spec/html/proofer/fixtures/vcr_cassettes/links/redirected_error_html.yml +0 -1044
- data/spec/html/proofer/fixtures/vcr_cassettes/links/utf8Link_html.yml +0 -113
- data/spec/html/proofer/fixtures/vcr_cassettes/scripts/script_broken_external_html.yml +0 -45
- data/spec/html/proofer/fixtures/vcr_cassettes/sorting/status_typhoeus_followlocation_false_error_sort_status_.yml +0 -244
- data/spec/html/proofer/fixtures/vcr_cassettes/sorting/status_verbosity_info_typhoeus_followlocation_false_error_sort_status_.yml +0 -244
- data/spec/html/proofer/fixtures/vcr_cassettes/www_garbalarba_com_href_swap_/garbalarba/_github_.yml +0 -73
- data/spec/html/proofer/fixtures/vcr_cassettes/www_github_com_foofoofoo_biz.yml +0 -115
- data/spec/html/proofer/html_spec.rb +0 -64
- data/spec/html/proofer/images_spec.rb +0 -147
- data/spec/html/proofer/links_spec.rb +0 -376
- data/spec/html/proofer/scripts_spec.rb +0 -46
- data/spec/html/proofer/utils_spec.rb +0 -14
- data/spec/html/proofer_spec.rb +0 -122
- data/spec/spec_helper.rb +0 -75
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Scripts test' do
|
4
|
-
|
5
|
-
it 'fails for broken external src' do
|
6
|
-
file = "#{FIXTURES_DIR}/scripts/script_broken_external.html"
|
7
|
-
proofer = run_proofer(file)
|
8
|
-
expect(proofer.failed_tests.first).to match(/failed: 0/)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'works for valid internal src' do
|
12
|
-
file = "#{FIXTURES_DIR}/scripts/script_valid_internal.html"
|
13
|
-
proofer = run_proofer(file)
|
14
|
-
expect(proofer.failed_tests).to eq []
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'fails for missing internal src' do
|
18
|
-
file = "#{FIXTURES_DIR}/scripts/script_missing_internal.html"
|
19
|
-
proofer = run_proofer(file)
|
20
|
-
expect(proofer.failed_tests.first).to match(/doesnotexist.js does not exist \(line 5\)/)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'works for present content' do
|
24
|
-
file = "#{FIXTURES_DIR}/scripts/script_content.html"
|
25
|
-
proofer = run_proofer(file)
|
26
|
-
expect(proofer.failed_tests).to eq []
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'fails for absent content' do
|
30
|
-
file = "#{FIXTURES_DIR}/scripts/script_content_absent.html"
|
31
|
-
proofer = run_proofer(file)
|
32
|
-
expect(proofer.failed_tests.first).to match(/script is empty and has no src attribute/)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'works for broken script within pre' do
|
36
|
-
script_pre = "#{FIXTURES_DIR}/scripts/script_in_pre.html"
|
37
|
-
proofer = run_proofer(script_pre)
|
38
|
-
expect(proofer.failed_tests).to eq []
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'ignores links via url_ignore' do
|
42
|
-
ignorableLinks = "#{FIXTURES_DIR}/scripts/ignorableLinksViaOptions.html"
|
43
|
-
proofer = run_proofer(ignorableLinks, { :url_ignore => [/\/assets\/.*(js|css|png|svg)/] })
|
44
|
-
expect(proofer.failed_tests).to eq []
|
45
|
-
end
|
46
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HTML::Proofer::Utils do
|
4
|
-
describe '::create_nokogiri' do
|
5
|
-
it 'passes for a string' do
|
6
|
-
noko = HTML::Proofer::Utils::create_nokogiri '<html lang="jp">'
|
7
|
-
expect(noko.css('html').first['lang']).to eq 'jp'
|
8
|
-
end
|
9
|
-
it 'passes for a file' do
|
10
|
-
noko = HTML::Proofer::Utils::create_nokogiri "#{FIXTURES_DIR}/utils/lang-jp.html"
|
11
|
-
expect(noko.css('html').first['lang']).to eq 'jp'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/spec/html/proofer_spec.rb
DELETED
@@ -1,122 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe HTML::Proofer do
|
4
|
-
|
5
|
-
describe '#failed_tests' do
|
6
|
-
it 'is a list of the formatted errors' do
|
7
|
-
brokenLinkInternalFilepath = "#{FIXTURES_DIR}/links/brokenLinkInternal.html"
|
8
|
-
proofer = run_proofer(brokenLinkInternalFilepath)
|
9
|
-
expect(proofer.failed_tests).to eq(["spec/html/proofer/fixtures/links/brokenLinkInternal.html: internally linking to ./notreal.html, which does not exist (line 5)", "spec/html/proofer/fixtures/links/brokenLinkInternal.html: internally linking to ./missingImageAlt.html, which does not exist (line 6)"])
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#files' do
|
14
|
-
it 'works for directory that ends with .html' do
|
15
|
-
folder = "#{FIXTURES_DIR}/links/_site/folder.html"
|
16
|
-
proofer = HTML::Proofer.new folder
|
17
|
-
expect(proofer.files).to eq(["#{folder}/index.html"])
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#options' do
|
22
|
-
it 'strips out undesired Typhoeus options' do
|
23
|
-
folder = "#{FIXTURES_DIR}/links/_site/folder.html"
|
24
|
-
proofer = HTML::Proofer.new folder, :verbose => true
|
25
|
-
expect(proofer.options[:verbose]).to eq(true)
|
26
|
-
expect(proofer.typhoeus_opts[:verbose]).to eq(nil)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'takes options for Parallel' do
|
30
|
-
folder = "#{FIXTURES_DIR}/links/_site/folder.html"
|
31
|
-
proofer = HTML::Proofer.new folder, :parallel => { :in_processes => 3 }
|
32
|
-
expect(proofer.parallel_opts[:in_processes]).to eq(3)
|
33
|
-
expect(proofer.typhoeus_opts[:in_processes]).to eq(nil)
|
34
|
-
expect(proofer.options[:parallel]).to eq(nil)
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'sorting' do
|
38
|
-
it 'understands sorting by path' do
|
39
|
-
output = send_proofer_output("#{FIXTURES_DIR}/sorting/path", :verbosity => :info)
|
40
|
-
|
41
|
-
expect(output.strip).to eq('''
|
42
|
-
- spec/html/proofer/fixtures/sorting/path/multiple_issues.html
|
43
|
-
* image gpl.png does not have an alt attribute (line 7)
|
44
|
-
* internal image gpl.png does not exist (line 7)
|
45
|
-
* tel: contains no phone number (line 5)
|
46
|
-
- spec/html/proofer/fixtures/sorting/path/single_issue.html
|
47
|
-
* image has a terrible filename (./Screen Shot 2012-08-09 at 7.51.18 AM.png) (line 1)
|
48
|
-
'''.strip)
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'understands sorting by issue' do
|
52
|
-
output = send_proofer_output("#{FIXTURES_DIR}/sorting/issue", :verbosity => :info, :error_sort => :desc)
|
53
|
-
expect(output.strip).to eq('''
|
54
|
-
- image ./gpl.png does not have an alt attribute
|
55
|
-
* spec/html/proofer/fixtures/sorting/issue/broken_image_one.html (line 1)
|
56
|
-
* spec/html/proofer/fixtures/sorting/issue/broken_image_two.html (line 1)
|
57
|
-
- internal image ./gpl.png does not exist
|
58
|
-
* spec/html/proofer/fixtures/sorting/issue/broken_image_one.html (line 1)
|
59
|
-
* spec/html/proofer/fixtures/sorting/issue/broken_image_two.html (line 1)
|
60
|
-
- internal image NOT_AN_IMAGE does not exist
|
61
|
-
* spec/html/proofer/fixtures/sorting/issue/broken_image_two.html (line 4)
|
62
|
-
'''.strip)
|
63
|
-
end
|
64
|
-
|
65
|
-
|
66
|
-
it 'understands sorting by status' do
|
67
|
-
output = send_proofer_output("#{FIXTURES_DIR}/sorting/status", :verbosity => :info, :typhoeus => { :followlocation => false }, :error_sort => :status)
|
68
|
-
expect(output.gsub(/\s*$/, '')).to eq('''
|
69
|
-
- -1
|
70
|
-
* spec/html/proofer/fixtures/sorting/status/broken_link.html: internally linking to nowhere.fooof, which does not exist (line 3)
|
71
|
-
- 301
|
72
|
-
* spec/html/proofer/fixtures/sorting/status/a_404.html: External link http://upload.wikimedia.org/wikipedia/en/thumb/not_here.png failed: 301
|
73
|
-
* spec/html/proofer/fixtures/sorting/status/broken_link.html: External link http://upload.wikimedia.org/wikipedia/en/thumb/fooooof.png failed: 301
|
74
|
-
'''.strip)
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe 'file ignores' do
|
79
|
-
it 'knows how to ignore a file by string' do
|
80
|
-
options = { :file_ignore => ["#{FIXTURES_DIR}/links/brokenHashInternal.html"] }
|
81
|
-
brokenHashInternalFilepath = "#{FIXTURES_DIR}/links/brokenHashInternal.html"
|
82
|
-
proofer = run_proofer(brokenHashInternalFilepath, options)
|
83
|
-
expect(proofer.failed_tests).to eq []
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'knows how to ignore a file by regexp' do
|
87
|
-
options = { :file_ignore => [/brokenHash/] }
|
88
|
-
brokenHashInternalFilepath = "#{FIXTURES_DIR}/links/brokenHashInternal.html"
|
89
|
-
proofer = run_proofer(brokenHashInternalFilepath, options)
|
90
|
-
expect(proofer.failed_tests).to eq []
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'knows how to ignore multiple files by regexp' do
|
94
|
-
options = { :file_ignore => [%r{.*/javadoc/.*}, %r{.*/catalog/.*}] }
|
95
|
-
brokenFolders = "#{FIXTURES_DIR}/links/folder/multiples"
|
96
|
-
proofer = run_proofer(brokenFolders, options)
|
97
|
-
expect(proofer.failed_tests).to eq []
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'knows how to ignore a directory by regexp' do
|
101
|
-
options = { :file_ignore => [/\S\.html/] }
|
102
|
-
linksDir = "#{FIXTURES_DIR}/links"
|
103
|
-
proofer = run_proofer(linksDir, options)
|
104
|
-
expect(proofer.failed_tests).to eq []
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe 'ignored checks' do
|
110
|
-
it 'knows how to ignore checks' do
|
111
|
-
options = { :checks_to_ignore => ['ImageRunner'] }
|
112
|
-
proofer = make_proofer('', options)
|
113
|
-
expect(proofer.checks).to_not include 'ImageRunner'
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'does not care about phoney ignored checks' do
|
117
|
-
options = { :checks_to_ignore => ['This is nothing.'] }
|
118
|
-
proofer = make_proofer('', options)
|
119
|
-
expect(proofer.checks.length).to eq 3
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'bundler/setup'
|
2
|
-
require 'vcr'
|
3
|
-
require_relative '../lib/html/proofer'
|
4
|
-
|
5
|
-
FIXTURES_DIR = 'spec/html/proofer/fixtures'
|
6
|
-
|
7
|
-
RSpec.configure do |config|
|
8
|
-
# Use color in STDOUT
|
9
|
-
config.color = true
|
10
|
-
|
11
|
-
# Use color not only in STDOUT but also in pagers and files
|
12
|
-
config.tty = true
|
13
|
-
|
14
|
-
# Use the specified formatter
|
15
|
-
config.formatter = :documentation # :progress, :html, :textmate
|
16
|
-
|
17
|
-
# Run in a random order
|
18
|
-
config.order = :random
|
19
|
-
end
|
20
|
-
|
21
|
-
def capture_stderr(*)
|
22
|
-
original_stderr = $stderr
|
23
|
-
original_stdout = $stdout
|
24
|
-
$stderr = fake_err = StringIO.new
|
25
|
-
$stdout = fake_out = StringIO.new
|
26
|
-
begin
|
27
|
-
yield
|
28
|
-
rescue RuntimeError
|
29
|
-
ensure
|
30
|
-
$stderr = original_stderr
|
31
|
-
$stdout = original_stdout
|
32
|
-
end
|
33
|
-
fake_err.string
|
34
|
-
end
|
35
|
-
|
36
|
-
def make_proofer(file, opts)
|
37
|
-
opts[:verbosity] ||= :fatal
|
38
|
-
HTML::Proofer.new(file, opts)
|
39
|
-
end
|
40
|
-
|
41
|
-
def run_proofer(file, opts = {})
|
42
|
-
cassette_name = make_cassette_name(file, opts)
|
43
|
-
proofer = make_proofer(file, opts)
|
44
|
-
VCR.use_cassette(cassette_name, :record => :new_episodes) do
|
45
|
-
capture_stderr { proofer.run }
|
46
|
-
proofer
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def send_proofer_output(file, opts = {})
|
51
|
-
cassette_name = make_cassette_name(file, opts)
|
52
|
-
proofer = make_proofer(file, opts)
|
53
|
-
VCR.use_cassette(cassette_name, :record => :new_episodes) do
|
54
|
-
capture_stderr { proofer.run }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def make_bin(cmd, path=nil)
|
59
|
-
`bin/htmlproof #{cmd} #{path}`
|
60
|
-
end
|
61
|
-
|
62
|
-
def make_cassette_name(file, opts)
|
63
|
-
filename = if file.is_a? Array
|
64
|
-
file.join('_')
|
65
|
-
else
|
66
|
-
file.split('/')[-2..-1].join('/')
|
67
|
-
end
|
68
|
-
(filename += opts.inspect) unless opts.empty?
|
69
|
-
filename
|
70
|
-
end
|
71
|
-
|
72
|
-
VCR.configure do |config|
|
73
|
-
config.cassette_library_dir = "#{FIXTURES_DIR}/vcr_cassettes"
|
74
|
-
config.hook_into :typhoeus
|
75
|
-
end
|