# frozen_string_literal: true # Used by executable to verify a particular web page require 'generic_test/setup' page = GenericTest.pages.first links = page.links RSpec.describe "#{page.title} Links respond" do links.each_with_index do |link, index| link_text = link.text.to_s.empty? ? '' : " \"#{link.text}\"" it "Link (#{index + 1})#{link_text} to '#{link.href}' succeeds" do expect(Checker.link_status(link.href)).to be_between 200, 399 end end end emails = page.emails RSpec.describe "#{page.title} Emails are valid" do emails.each do |email| it "Email (#{email}) is valid" do expect(Checker.valid_email?(email)).to be nil end end end RSpec.describe "#{page.title} Page content" do spellcheck_report = SpellCheck::ProofReader.check(page.text) context 'does not have common spelling mistakes' do it 'has no mistakes' do expect(spellcheck_report.errata.size).to eq 0 end spellcheck_report.errata.group_by(&:line_number).each do |line_number, mistakes| context "Line #{line_number}" do mistakes.each_with_index do |mistake, index| it "(#{index + 1}) #{mistake.pattern}" do expect(mistake.pattern).to eq mistake.expected end end end end end end