From 2dbcdcf24d73d04d890a359368418b1babefa5d9 Mon Sep 17 00:00:00 2001 From: Michael Ball Date: Tue, 13 Aug 2024 03:49:55 -0700 Subject: [PATCH] Specs: always build jekyll site --- .github/workflows/rspec.yml | 2 +- spec/spec_helper.rb | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index a5cd367..13af5bf 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -23,4 +23,4 @@ jobs: bundle exec rspec - name: summary if: always() - run: ruby specs/support/spec_summary.rb + run: ruby spec/support/spec_summary.rb diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f0e5be7..7a831c4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,6 +16,7 @@ # # See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +require 'jekyll' require 'rspec' require 'rack' require 'yaml' @@ -30,23 +31,29 @@ require 'axe-rspec' require 'axe-capybara' -RSPEC_CONFIG_FILE = '_config.yml' or ENV.fetch('RSPEC_CONFIG_FILE', nil) - +# ------------ +# Tools to build / compile the Jekyll site and extract the sitemap def site_config - @site_config ||= YAML.load_file(RSPEC_CONFIG_FILE) + # TODO(template): We should standardize the build for specs + # Consider simplifying baseurl + # Consider forcing the desination folder + # Override the local URL too? Would it break the sitemap? + # Note: Config keys must be strings and thus use => style hashes. + @config ||= ::Jekyll.configuration({ + 'sass' => { 'quiet_deps' => true } + }) end -def site_url - @site_url ||= site_config['url'] + site_config['baseurl'] -end +@site = ::Jekyll::Site.new(site_config) +@site.process +puts "Site build complete" def load_site_urls - puts "Running accessibility tests, expected deploy URL: #{site_url}" - # TODO: Handle case where build is not in _site + puts "Running accessibility tests" sitemap_text = File.read('_site/sitemap.xml') sitemap_links = sitemap_text.scan(%r{.+}) sitemap_links.filter_map do |link| - link = link.gsub("#{site_url}", '').gsub('', '') + link = link.gsub("#{site_config['url']}", '').gsub('', '') # Skip non-html pages # (FUTURE?) Are there other pages that should be audited for accessibility? # (e.g. PDFs, documents. They'd need a different checker.) @@ -55,7 +62,6 @@ def load_site_urls link end.sort end - # -------- # This is the root of the repository, e.g. the bjc-r directory