# frozen_string_literal: true

if ENV['CI']
  require 'simplecov'
  require 'coveralls'

  SimpleCov.formatter = Coveralls::SimpleCov::Formatter
  SimpleCov.start do
    %w[spec].each do |ignore_path|
      add_filter(ignore_path)
    end
  end
end

require 'bundler/setup'
require 'rubocop_auto_corrector'
require 'rubocop_auto_corrector/cli'
require 'rspec/temp_dir'
require 'rspec/parameterized'

Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }

RSpec.configure do |config|
  # Enable flags like --only-failures and --next-failure
  config.example_status_persistence_file_path = '.rspec_status'

  # Disable RSpec exposing methods globally on `Module` and `main`
  config.disable_monkey_patching!

  config.expect_with :rspec do |c|
    c.syntax = :expect
  end
end

def spec_dir
  Pathname(__dir__)
end

def system!(command)
  ret = system(command)
  raise "`#{command}` is failed" unless ret
end
