Skip to content

Commit

Permalink
fix images snake_case
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengroat committed May 12, 2017
1 parent fce32f5 commit 5b390d2
Show file tree
Hide file tree
Showing 27 changed files with 82 additions and 82 deletions.
30 changes: 15 additions & 15 deletions spec/html-proofer/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
end

it 'works with alt-ignore' do
ignorableLinks = "#{FIXTURES_DIR}/images/ignorableAltViaOptions.html"
output = make_bin('--alt-ignore /wikimedia/,gpl.png', ignorableLinks)
ignorable_links = "#{FIXTURES_DIR}/images/ignorable_alt_via_options.html"
output = make_bin('--alt-ignore /wikimedia/,gpl.png', ignorable_links)
expect(output).to match('successfully')
end

Expand All @@ -20,8 +20,8 @@
end

it 'works with check-external-hash' do
brokenHashOnTheWeb = "#{FIXTURES_DIR}/links/brokenHashOnTheWeb.html"
output = make_bin('--check-external-hash', brokenHashOnTheWeb)
broken_hash_on_the_web = "#{FIXTURES_DIR}/links/broken_hash_on_the_web.html"
output = make_bin('--check-external-hash', broken_hash_on_the_web)
expect(output).to match('1 failure')
end

Expand Down Expand Up @@ -51,32 +51,32 @@
end

it 'works with internal-domains' do
translatedLink = "#{FIXTURES_DIR}/links/linkTranslatedInternalDomains.html"
output = make_bin('--internal-domains www.example.com,example.com', translatedLink)
translated_link = "#{FIXTURES_DIR}/links/link_translated_internal_domains.html"
output = make_bin('--internal-domains www.example.com,example.com', translated_link)
expect(output).to match('successfully')
end

it 'works with url-ignore' do
ignorableLinks = "#{FIXTURES_DIR}/links/ignorableLinksViaOptions.html"
output = make_bin('--url-ignore /^http:\/\//,/sdadsad/,../whaadadt.html', ignorableLinks)
ignorable_links = "#{FIXTURES_DIR}/links/ignorable_links_via_options.html"
output = make_bin('--url-ignore /^http:\/\//,/sdadsad/,../whaadadt.html', ignorable_links)
expect(output).to match('successfully')
end

it 'works with url-swap' do
translatedLink = "#{FIXTURES_DIR}/links/linkTranslatedViaHrefSwap.html"
output = make_bin('--url-swap "\A/articles/([\w-]+):\1.html"', translatedLink)
translated_link = "#{FIXTURES_DIR}/links/link_translated_via_href_swap.html"
output = make_bin('--url-swap "\A/articles/([\w-]+):\1.html"', translated_link)
expect(output).to match('successfully')
end

it 'works with url-swap and colon' do
translatedLink = "#{FIXTURES_DIR}/links/linkTranslatedViaHrefSwap2.html"
output = make_bin('--url-swap "http\://www.example.com:"', translatedLink)
translated_link = "#{FIXTURES_DIR}/links/link_translated_via_href_swap2.html"
output = make_bin('--url-swap "http\://www.example.com:"', translated_link)
expect(output).to match('successfully')
end

it 'works with only-4xx' do
brokenHashOnTheWeb = "#{FIXTURES_DIR}/links/brokenHashOnTheWeb.html"
output = make_bin('--only-4xx', brokenHashOnTheWeb)
broken_hash_on_the_web = "#{FIXTURES_DIR}/links/broken_hash_on_the_web.html"
output = make_bin('--only-4xx', broken_hash_on_the_web)
expect(output).to match('successfully')
end

Expand All @@ -93,7 +93,7 @@
end

it 'works with empty-alt-ignore' do
broken = "#{FIXTURES_DIR}/html/emptyImageAltText.html"
broken = "#{FIXTURES_DIR}/html/empty_image_alt_text.html"
output = make_bin('--empty-alt-ignore', broken)
expect(output).to match('successfully')
end
Expand Down
4 changes: 2 additions & 2 deletions spec/html-proofer/favicon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
end

it 'translates links via url_swap' do
translatedLink = "#{FIXTURES_DIR}/favicon/favicon_broken.html"
proofer = run_proofer(translatedLink, :file, check_favicon: true, url_swap: { /^asdadaskdalsdk.+/ => '../resources/gpl.png' })
translated_link = "#{FIXTURES_DIR}/favicon/favicon_broken.html"
proofer = run_proofer(translated_link, :file, check_favicon: true, url_swap: { /^asdadaskdalsdk.+/ => '../resources/gpl.png' })
expect(proofer.failed_tests).to eq []
end

Expand Down
10 changes: 5 additions & 5 deletions spec/html-proofer/html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@

it 'ignores embeded scripts when asked' do
opts = { check_html: true, validation: { report_script_embeds: false } }
ignorableScript = "#{FIXTURES_DIR}/html/ignore_script_embeds.html"
proofer = run_proofer(ignorableScript, :file, opts)
ignorable_script = "#{FIXTURES_DIR}/html/ignore_script_embeds.html"
proofer = run_proofer(ignorable_script, :file, opts)
expect(proofer.failed_tests).to eq []
end

it 'reports embeded scripts when asked' do
opts = { check_html: true, validation: { report_script_embeds: true } }
ignorableScript = "#{FIXTURES_DIR}/html/ignore_script_embeds.html"
proofer = run_proofer(ignorableScript, :file, opts)
ignorable_script = "#{FIXTURES_DIR}/html/ignore_script_embeds.html"
proofer = run_proofer(ignorable_script, :file, opts)
expect(proofer.failed_tests.length).to eq 2
end

Expand Down Expand Up @@ -111,7 +111,7 @@

it 'ignores namespaces' do
opts = { check_html: true }
ignorableNamespace = "#{FIXTURES_DIR}/html/ignore_namespace.html"
ignorable_namespace = "#{FIXTURES_DIR}/html/ignore_namespace.html"
proofer = run_proofer(ignorableNamespace, :file, opts)
expect(proofer.failed_tests).to eq []
end
Expand Down
120 changes: 60 additions & 60 deletions spec/html-proofer/images_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,177 +2,177 @@

describe 'Images test' do
it 'passes for existing external images' do
externalImageFilepath = "#{FIXTURES_DIR}/images/existingImageExternal.html"
proofer = run_proofer(externalImageFilepath, :file)
external_image_filepath = "#{FIXTURES_DIR}/images/existing_image_external.html"
proofer = run_proofer(external_image_filepath, :file)
expect(proofer.failed_tests).to eq []
end

it 'fails for image without alt attribute' do
missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAlt.html"
proofer = run_proofer(missingAltFilepath, :file)
missing_alt_filepath = "#{FIXTURES_DIR}/images/missing_image_alt.html"
proofer = run_proofer(missing_alt_filepath, :file)
expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
end

it 'fails for image with an empty alt attribute' do
missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAltText.html"
proofer = run_proofer(missingAltFilepath, :file)
missing_alt_filepath = "#{FIXTURES_DIR}/images/missing_image_alt_text.html"
proofer = run_proofer(missing_alt_filepath, :file)
expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
end

it 'fails for image with nothing but spaces in alt attribute' do
emptyAltFilepath = "#{FIXTURES_DIR}/images/emptyImageAltText.html"
proofer = run_proofer(emptyAltFilepath, :file)
empty_alt_filepath = "#{FIXTURES_DIR}/images/empty_image_alt_text.html"
proofer = run_proofer(empty_alt_filepath, :file)
expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
expect(proofer.failed_tests.length).to equal(3)
end

it 'passes when ignoring image with nothing but spaces in alt attribute' do
emptyAltFilepath = "#{FIXTURES_DIR}/images/emptyImageAltText.html"
proofer = run_proofer(emptyAltFilepath, :file, alt_ignore: [/.+/])
empty_alt_filepath = "#{FIXTURES_DIR}/images/empty_image_alt_text.html"
proofer = run_proofer(empty_alt_filepath, :file, alt_ignore: [/.+/])
expect(proofer.failed_tests).to eq []
end

it 'fails for missing external images' do
externalImageFilepath = "#{FIXTURES_DIR}/images/missingImageExternal.html"
proofer = run_proofer(externalImageFilepath, :file)
external_image_filepath = "#{FIXTURES_DIR}/images/missing_image_external.html"
proofer = run_proofer(external_image_filepath, :file)
expect(proofer.failed_tests.first).to match(/failed: response code 0/)
end

it 'fails for missing internal images even when alt_ignore is set' do
internalImageFilepath = "#{FIXTURES_DIR}/images/missingImageInternal.html"
proofer = run_proofer(internalImageFilepath, :file, alt_ignore: [/.*/])
internal_image_filepath = "#{FIXTURES_DIR}/images/missing_image_internal.html"
proofer = run_proofer(internal_image_filepath, :file, alt_ignore: [/.*/])
expect(proofer.failed_tests.first).to match(/doesnotexist.png does not exist/)
end

it 'fails for missing internal images' do
internalImageFilepath = "#{FIXTURES_DIR}/images/missingImageInternal.html"
proofer = run_proofer(internalImageFilepath, :file)
internal_image_filepath = "#{FIXTURES_DIR}/images/missing_image_internal.html"
proofer = run_proofer(internal_image_filepath, :file)
expect(proofer.failed_tests.first).to match(/doesnotexist.png does not exist/)
end

it 'fails for image with no src' do
imageSrcFilepath = "#{FIXTURES_DIR}/images/missingImageSrc.html"
proofer = run_proofer(imageSrcFilepath, :file)
image_src_filepath = "#{FIXTURES_DIR}/images/missing_image_src.html"
proofer = run_proofer(image_src_filepath, :file)
expect(proofer.failed_tests.first).to match(/image has no src or srcset attribute/)
end

it 'fails for image with default mac filename' do
terribleImageName = "#{FIXTURES_DIR}/images/terribleImageName.html"
proofer = run_proofer(terribleImageName, :file)
terrible_image_name = "#{FIXTURES_DIR}/images/terrible_image_name.html"
proofer = run_proofer(terrible_image_name, :file)
expect(proofer.failed_tests.first).to match(/image has a terrible filename/)
end

it 'ignores images marked as ignore data-proofer-ignore' do
ignorableImages = "#{FIXTURES_DIR}/images/ignorableImages.html"
proofer = run_proofer(ignorableImages, :file)
ignorable_images = "#{FIXTURES_DIR}/images/ignorable_images.html"
proofer = run_proofer(ignorable_images, :file)
expect(proofer.failed_tests).to eq []
end

it 'ignores images via url_ignore' do
ignorableImage = "#{FIXTURES_DIR}/images/terribleImageName.html"
proofer = run_proofer(ignorableImage, :file, url_ignore: [%r{./Screen.+}])
ignorable_image = "#{FIXTURES_DIR}/images/terrible_image_name.html"
proofer = run_proofer(ignorable_image, :file, url_ignore: [%r{./Screen.+}])
expect(proofer.failed_tests).to eq []
end

it 'translates images via url_swap' do
translatedLink = "#{FIXTURES_DIR}/images/terribleImageName.html"
proofer = run_proofer(translatedLink, :file, url_swap: { %r{./Screen.+} => 'gpl.png' })
translated_link = "#{FIXTURES_DIR}/images/terrible_image_name.html"
proofer = run_proofer(translated_link, :file, url_swap: { %r{./Screen.+} => 'gpl.png' })
expect(proofer.failed_tests).to eq []
end

it 'properly checks relative images' do
relativeImages = "#{FIXTURES_DIR}/images/rootRelativeImages.html"
proofer = run_proofer(relativeImages, :file)
relative_images = "#{FIXTURES_DIR}/images/root_relative_images.html"
proofer = run_proofer(relative_images, :file)
expect(proofer.failed_tests).to eq []

relativeImages = "#{FIXTURES_DIR}/resources/books/nestedRelativeImages.html"
proofer = run_proofer(relativeImages, :file)
relative_images = "#{FIXTURES_DIR}/resources/books/nested_relative_images.html"
proofer = run_proofer(relative_images, :file)
expect(proofer.failed_tests).to eq []
end

it 'properly ignores data URI images' do
dataURIImage = "#{FIXTURES_DIR}/images/workingDataURIImage.html"
proofer = run_proofer(dataURIImage, :file)
data_uri_image = "#{FIXTURES_DIR}/images/working_data_uri_image.html"
proofer = run_proofer(data_uri_image, :file)
expect(proofer.failed_tests).to eq []
end

it 'works for valid images missing the protocol' do
missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_valid.html"
proofer = run_proofer(missingProtocolLink, :file)
missing_protocol_link = "#{FIXTURES_DIR}/images/image_missing_protocol_valid.html"
proofer = run_proofer(missing_protocol_link, :file)
expect(proofer.failed_tests).to eq []
end

it 'fails for invalid images missing the protocol' do
missingProtocolLink = "#{FIXTURES_DIR}/images/image_missing_protocol_invalid.html"
proofer = run_proofer(missingProtocolLink, :file)
missing_protocol_link = "#{FIXTURES_DIR}/images/image_missing_protocol_invalid.html"
proofer = run_proofer(missing_protocol_link, :file)
expect(proofer.failed_tests.first).to match(/failed: 404/)
end

it 'properly checks relative links' do
relativeLinks = "#{FIXTURES_DIR}/images/relativeToSelf.html"
proofer = run_proofer(relativeLinks, :file)
relative_links = "#{FIXTURES_DIR}/images/relative_to_self.html"
proofer = run_proofer(relative_links, :file)
expect(proofer.failed_tests).to eq []
end

it 'properly ignores missing alt tags when asked' do
ignorableLinks = "#{FIXTURES_DIR}/images/ignorableAltViaOptions.html"
proofer = run_proofer(ignorableLinks, :file, alt_ignore: [/wikimedia/, 'gpl.png'])
ignoreable_links = "#{FIXTURES_DIR}/images/ignorable_alt_via_options.html"
proofer = run_proofer(ignoreable_links, :file, alt_ignore: [/wikimedia/, 'gpl.png'])
expect(proofer.failed_tests).to eq []
end

it 'properly ignores missing alt tags, but not all URLs, when asked' do
ignorableLinks = "#{FIXTURES_DIR}/images/ignoreAltButNotLink.html"
proofer = run_proofer(ignorableLinks, :file, alt_ignore: [/.*/])
ignoreable_links = "#{FIXTURES_DIR}/images/ignore_alt_but_not_link.html"
proofer = run_proofer(ignoreable_links, :file, alt_ignore: [/.*/])
expect(proofer.failed_tests.first).to match(/failed: response code 0/)
expect(proofer.failed_tests.first).to_not match /does not have an alt attribute/
end

it 'properly ignores empty alt attribute when empty_alt_ignore set' do
missingAltFilepath = "#{FIXTURES_DIR}/images/emptyImageAltText.html"
proofer = run_proofer(missingAltFilepath, :file, empty_alt_ignore: true)
missing_alt_filepath = "#{FIXTURES_DIR}/images/empty_image_alt_text.html"
proofer = run_proofer(missing_alt_filepath, :file, empty_alt_ignore: true)
expect(proofer.failed_tests).to eq []
end

it 'properly ignores empty alt attributes, but not missing alt attributes, when empty_alt_ignore set' do
missingAltFilepath = "#{FIXTURES_DIR}/images/missingImageAlt.html"
proofer = run_proofer(missingAltFilepath, :file, empty_alt_ignore: true)
missing_alt_filepath = "#{FIXTURES_DIR}/images/missing_image_alt.html"
proofer = run_proofer(missing_alt_filepath, :file, empty_alt_ignore: true)
expect(proofer.failed_tests.first).to match(/gpl.png does not have an alt attribute/)
end

it 'works for images with a srcset' do
srcSetCheck = "#{FIXTURES_DIR}/images/srcSetCheck.html"
proofer = run_proofer(srcSetCheck, :file)
src_set_check = "#{FIXTURES_DIR}/images/src_set_check.html"
proofer = run_proofer(src_set_check, :file)
expect(proofer.failed_tests).to eq []
end

it 'skips missing alt tag for images marked as aria-hidden' do
srcSetCheck = "#{FIXTURES_DIR}/images/ariaHidden.html"
proofer = run_proofer(srcSetCheck, :file)
src_set_check = "#{FIXTURES_DIR}/images/aria_hidden.html"
proofer = run_proofer(src_set_check, :file)
expect(proofer.failed_tests.size).to eq 1
expect(proofer.failed_tests.first).to match(/image .\/gpl.png does not have an alt attribute/)
end

it 'fails for images with a srcset but missing alt' do
srcSetMissingAlt = "#{FIXTURES_DIR}/images/srcSetMissingAlt.html"
proofer = run_proofer(srcSetMissingAlt, :file)
src_set_missing_alt = "#{FIXTURES_DIR}/images/src_set_missing_alt.html"
proofer = run_proofer(src_set_missing_alt, :file)
expect(proofer.failed_tests.first).to match(/image gpl.png does not have an alt attribute/)
end

it 'fails for images with an alt but missing src or srcset' do
srcSetMissingAlt = "#{FIXTURES_DIR}/images/srcSetMissingImage.html"
proofer = run_proofer(srcSetMissingAlt, :file)
src_set_missing_alt = "#{FIXTURES_DIR}/images/src_set_missing_image.html"
proofer = run_proofer(src_set_missing_alt, :file)
expect(proofer.failed_tests.first).to match(/internal image notreal.png does not exist/)
end

it 'properly ignores missing alt tags when asked for srcset' do
ignorableLinks = "#{FIXTURES_DIR}/images/srcSetIgnorable.html"
proofer = run_proofer(ignorableLinks, :file, alt_ignore: [/wikimedia/, 'gpl.png'])
ignoreable_links = "#{FIXTURES_DIR}/images/src_set_ignorable.html"
proofer = run_proofer(ignoreable_links, :file, alt_ignore: [/wikimedia/, 'gpl.png'])
expect(proofer.failed_tests).to eq []
end

it 'translates src via href_swap' do
translatedSrc = "#{FIXTURES_DIR}/images/replaceAbsUrlSrc.html"
proofer = run_proofer(translatedSrc, :file, href_swap: { %r{^http://example.com} => '' })
translate_src = "#{FIXTURES_DIR}/images/replace_abs_url_src.html"
proofer = run_proofer(translate_src, :file, href_swap: { %r{^http://example.com} => '' })
expect(proofer.failed_tests).to eq []
end

Expand All @@ -189,8 +189,8 @@
end

it 'properly checks relative images with base' do
relativeImages = "#{FIXTURES_DIR}/images/relativeWithBase.html"
proofer = run_proofer(relativeImages, :file)
relative_images = "#{FIXTURES_DIR}/images/relative_with_base.html"
proofer = run_proofer(relative_images, :file)
expect(proofer.failed_tests).to eq []
end
end

0 comments on commit 5b390d2

Please sign in to comment.