class RSpectre::Runner

Constants

EXIT_SUCCESS

Attributes

rspec_output[R]

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/rspectre/runner.rb, line 9
def initialize(*)
  super
  @rspec_output = StringIO.new
end

Public Instance Methods

lint() click to toggle source
# File lib/rspectre/runner.rb, line 14
def lint
  if run_specs.equal?(EXIT_SUCCESS)
    handle_offenses
  else
    exit_with_error
  end
end

Private Instance Methods

exit_with_error() click to toggle source

The version of `rubocop` we are currently using has an issue with leading whitespace in heredocs. rubocop:disable Layout/EmptyLinesAroundArguments

# File lib/rspectre/runner.rb, line 37
    def exit_with_error
      rspec_output.rewind

      abort(
        Color.red(
          'Running the specs failed. Either your tests do not pass '\
          'normally or this is a bug in RSpectre.'
        ) + <<~TEXT


          RSpec Output:
          ---
          #{rspec_output.read}
        TEXT
      )
    end
handle_offenses() click to toggle source
# File lib/rspectre/runner.rb, line 26
def handle_offenses
  if TRACKER.offenses?
    auto_correct ? TRACKER.correct_offenses : TRACKER.report_offenses
  else
    puts 'No unused test setup detected.'
  end
end
run_specs() click to toggle source

rubocop:enable Layout/EmptyLinesAroundArguments

# File lib/rspectre/runner.rb, line 55
def run_specs
  RSpec::Core::Runner.run(rspec_arguments, $stderr, rspec_output)
end