Module: Stormbreaker

Defined in:
lib/stormbreaker/axe_helper.rb,
lib/stormbreaker.rb,
lib/stormbreaker/version.rb,
lib/stormbreaker/axe_violation.rb,
lib/stormbreaker/configuration.rb,
lib/stormbreaker/erb_formatter.rb,
lib/stormbreaker/axe_rspec_auditor.rb,
lib/stormbreaker/axe_matcher_auditor.rb,
lib/stormbreaker/axe_results_reporter.rb,
lib/stormbreaker/axe_violation_manager.rb,
lib/stormbreaker/axe_results_serializer.rb

Overview

::RSpec::Core::Formatters::BaseTextFormatter.prepend AxeResultsReporter

Defined Under Namespace

Modules: AxeMatcherAuditor, AxeRSpecAuditor, AxeResultsReporter Classes: AxeHelper, AxeResultsSerializer, AxeViolation, AxeViolationManager, Configuration, ErbFormatter

Constant Summary collapse

VERSION =
"1.0.0"
ALL_SEVERITY_CATEGORIES =
%i[critical serious moderate minor].freeze

Class Method Summary collapse

Class Method Details

.configurationObject



6
7
8
# File 'lib/stormbreaker/configuration.rb', line 6

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



14
15
16
# File 'lib/stormbreaker/configuration.rb', line 14

def self.configure
  yield(configuration)
end

.configure_rspec_hooksObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/stormbreaker.rb', line 27

def self.configure_rspec_hooks
  RSpec.configure do |config|
    config.before(:each) do
      Stormbreaker::AxeHelper.post_test_cleanup
    end

    config.before(:suite) do
      Stormbreaker::AxeHelper.post_total_cleanup
    end

    config.after(:each) do
      unless Stormbreaker::AxeHelper.example_passed?
        raise RSpec::Expectations::ExpectationNotMetError, Stormbreaker::AxeHelper.detailed_results
      end
    end

    config.after(:suite) do
      erb_writer = Stormbreaker::ErbFormatter.new(Stormbreaker::AxeHelper.manager.total_violations)
      erb_writer.write_to_erb

      if Stormbreaker.configuration.serialize_output
        Stormbreaker::AxeResultsSerializer.serialize_results(Stormbreaker::AxeHelper.manager.total_violations)
      end
    end
  end
end

.configured_driverObject



40
41
42
43
44
45
46
47
# File 'lib/stormbreaker/configuration.rb', line 40

def self.configured_driver
  # Driver may be a lambda
  @configured_driver ||= if configuration.driver.respond_to?(:call)
                           configuration.driver.call
                         else
                           configuration.driver
                         end
end

.install!Object



20
21
22
23
24
25
# File 'lib/stormbreaker.rb', line 20

def self.install!
  ::RSpec::Expectations::ExpectationTarget.prepend AxeRSpecAuditor
  ::Axe::Matchers::BeAxeClean.prepend AxeMatcherAuditor
  ::RSpec::Core::Formatters::BaseTextFormatter.prepend AxeResultsReporter
  configure_rspec_hooks
end

.reset!Object



10
11
12
# File 'lib/stormbreaker/configuration.rb', line 10

def self.reset!
  @configuration = Configuration.new
end