# SimpleCov lines need to be at the top of this file!
require 'simplecov'
SimpleCov.start do
  formatter SimpleCov::Formatter::MultiFormatter[
    SimpleCov::Formatter::HTMLFormatter
  ]
end
require 'yarjuf'

# ERDL raises a runtime exception when required, if ENV does not contain all the envs listed in .env.example
# This is needed to ensure that the application doesn't fail in a strange way, when, for example it attempts to
# fill in YouTube login page with blank values (because .env does not exist, etc.)
#
# Thus, we will go ahead and load the .env.example to ENV in our tests. (The application itself loads .env though.)
require 'dotenv'
env_example = File.dirname(__FILE__) + '/../.env.example'
Dotenv.load(env_example)

# Used by some specs
require 'fakefs/safe'
require 'climate_control'

require File.dirname(__FILE__) + '/../lib/erdl.rb'

RSpec.configure do |config|
  config.expect_with :rspec do |expectations|
    expectations.include_chain_clauses_in_custom_matcher_descriptions = true
  end
  config.mock_with :rspec do |mocks|
    mocks.verify_partial_doubles = true
  end

  config.disable_monkey_patching!

  # This setting enables warnings. It's recommended, but in some cases may
  # be too noisy due to issues in dependencies.
  config.warnings = false
  config.default_formatter = 'doc' if config.files_to_run.one?
  # config.profile_examples = 10 # profile the N slowest tests

  config.order = :random
  # Seed global randomization in this process using the `--seed` CLI option.
  # Setting this allows you to use `--seed` to deterministically reproduce
  # test failures related to randomization by passing the same `--seed` value
  # as the one that triggered the failure.
  Kernel.srand config.seed
end
