dgollahon/rspectre

View on GitHub
bin/rspectre

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
# frozen_string_literal: true

$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))

require 'shellwords'
require 'optparse'

require 'rspectre'

options = { rspec: %w[--fail-fast spec], 'auto-correct': false }

OptionParser.new do |opts|
  opts.banner = 'Usage: rspectre [options]'

  opts.on('--rspec RSPEC_ARGS', 'Arguments to feed to RSpec.') do |value|
    options[:rspec] = value.shellsplit
  end

  opts.on(
    '--auto-correct',
    'Enables auto-correct.',
    'When auto-correct is enabled, rspectre will modify your source files in place and delete ' \
    'any unused test setup.'
  ) do |value|
    options[:'auto-correct'] = value
  end
end.parse(ARGV)

rspec, auto_correct = options.fetch_values(:rspec, :'auto-correct')

RSpectre::Runner.new(rspec_arguments: rspec, auto_correct: auto_correct).lint