Skip to content

Commit

Permalink
a11y: Cleanup some test summary stuff..
Browse files Browse the repository at this point in the history
  • Loading branch information
cycomachead committed Jun 19, 2024
1 parent dbed666 commit 71e3468
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 45 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/specs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ jobs:
bundler-cache: true
- name: ${{ matrix.course }} - a11y tests
run: bundle exec rspec utilities/spec --tag ${{ matrix.course }}
- name: ${{ matrix.course }} - a11y summary
run: ruby utilities/spec_summary.rb
7 changes: 7 additions & 0 deletions utilities/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
require 'capybara/dsl'
require 'capybara/session'

require_relative './spec_summary'

# This is the root of the repository, e.g. the bjc-r directory
# Update this is you move this file.
REPO_ROOT = File.expand_path('../../', __dir__)
Expand Down Expand Up @@ -128,4 +130,9 @@ def exists?(path)
# inherited by the metadata hash of host groups and examples, rather than
# triggering implicit auto-inclusion in groups with matching metadata.
config.shared_context_metadata_behavior = :apply_to_host_groups

# config.after(:suite) do
# # defined in the spec_summary file
# print_summary
# end
end
32 changes: 32 additions & 0 deletions utilities/spec/spec_summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

# Summarize the axe rspec failures into aggregate counts
# TODO: This should be an RSpec formatter

require 'json'
require 'pp'

RESULTS_PATH = File.join(File.dirname(__FILE__), '..', '..', 'tmp/rspec_output.json')
AXE_CASE_TITLE = /\n\s*\n\s*\d+\)\s+([-\w]+):/


def failing_specs(results_data)
results_data['examples'].filter do |ex|
ex['status'] == 'failed'
end
end

def summarize_results(results)
failing_specs(results).map do |ex|
ex['exception']['message'].scan(AXE_CASE_TITLE)
end.flatten.tally
end

def print_summary
results_data = JSON.parse(File.read(RESULTS_PATH))
failing_tests_by_type = summarize_results(results_data)
pp(failing_tests_by_type)
puts "Total: #{failing_tests_by_type.values.sum} failures."
end

print_summary
43 changes: 0 additions & 43 deletions utilities/spec_summary.rb

This file was deleted.

0 comments on commit 71e3468

Please sign in to comment.