Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never needed to raise #609

Merged
merged 4 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Install libxslt and libxml2
run: sudo apt-get install libxslt-dev libxml2-dev
- name: Set up Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
# bundler-cache: true
- name: Install libxslt and libxml2
run: sudo apt-get install libxslt-dev libxml2-dev
- name: Install dependencies
run: bundle install
- name: Run tests
Expand Down
14 changes: 0 additions & 14 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
AllCops:
Exclude:
- "vendor/**/*"

inherit_gem:
rubocop-standard:
- config/default.yml

Style/StringLiterals:
Enabled: true
EnforcedStyle: single_quotes

Naming/FileName:
Enabled: false

Style/Documentation:
Enabled: false
2 changes: 2 additions & 0 deletions lib/html-proofer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# rubocop:disable Naming/FileName
# frozen_string_literal: true

def require_all(path)
Expand Down Expand Up @@ -52,3 +53,4 @@ def self.check_links(links, options = {})
HTMLProofer::Runner.new(links, options)
end
end
# rubocop:enable Naming/FileName
3 changes: 2 additions & 1 deletion lib/html-proofer/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ def print_failed_tests
sorted_failures.sort_and_report
count = @failures.length
failure_text = pluralize(count, 'failure', 'failures')
raise @logger.colorize :fatal, "HTML-Proofer found #{failure_text}!"
@logger.log :fatal, "\nHTML-Proofer found #{failure_text}!"
exit 1
end

# Set before_request callback.
Expand Down
2 changes: 1 addition & 1 deletion lib/html-proofer/url_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def establish_queue(external_urls)
def clean_url(href)
# catch any obvious issues, like strings in port numbers
parsed = Addressable::URI.parse(href)
if href =~ /^([!#{$&}-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/
if href =~ /^([!#{Regexp.last_match(0)}-;=?-\[\]_a-z~]|%[0-9a-fA-F]{2})+$/
href
else
parsed.normalize
Expand Down
7 changes: 7 additions & 0 deletions spec/html-proofer/fixtures/links/hash/inner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<small><a href='#english'>English below</a></small>

<br>
<br>

<h3 id="english">English</h3>

7 changes: 6 additions & 1 deletion spec/html-proofer/proofer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
<a href="tel:">Tel me</a>
- spec/html-proofer/fixtures/sorting/path/single_issue.html
* image has a terrible filename (./Screen Shot 2012-08-09 at 7.51.18 AM.png) (line 1)

HTML-Proofer found 4 failures!
'.strip)
end

Expand All @@ -71,6 +73,8 @@
* spec/html-proofer/fixtures/sorting/issue/broken_image_two.html (line 1)
- internal image NOT_AN_IMAGE does not exist
* spec/html-proofer/fixtures/sorting/issue/broken_image_two.html (line 4)

HTML-Proofer found 5 failures!
'.strip)
end

Expand All @@ -82,7 +86,8 @@
- 301
* spec/html-proofer/fixtures/sorting/status/a_404.html: External link http://upload.wikimedia.org/wikipedia/en/thumb/not_here.png failed: 301
* spec/html-proofer/fixtures/sorting/status/broken_link.html: External link http://upload.wikimedia.org/wikipedia/en/thumb/fooooof.png failed: 301
'.strip)
HTML-Proofer found 3 failures!
'.strip)
end
end

Expand Down
6 changes: 4 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'vcr'
require 'timecop'
require_relative '../lib/html-proofer'
require 'open3'

FIXTURES_DIR = 'spec/html-proofer/fixtures'

Expand All @@ -28,7 +29,7 @@ def capture_stderr(*)
$stdout = StringIO.new unless ENV['VERBOSE']
begin
yield
rescue RuntimeError # rubocop:disable Lint/SuppressedException
rescue SystemExit # rubocop:disable Lint/SuppressedException
ensure
$stderr = original_stderr
$stdout = original_stdout unless ENV['VERBOSE']
Expand Down Expand Up @@ -68,7 +69,8 @@ def send_proofer_output(file, type, opts = {})
end

def make_bin(cmd, path = nil)
`bin/htmlproofer #{cmd} #{path}`
stdout, stderr = Open3.capture3("bin/htmlproofer #{cmd} #{path}")
"#{stdout}\n#{stderr}"
end

def make_cassette_name(file, opts)
Expand Down