summaryrefslogtreecommitdiff
path: root/spec/spec_helper.rb
blob: 365cdc6f33e47df001e210bc7fd04cebdef7db69 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# frozen_string_literal: true

require_relative 'ignore-gem-warnings' if $VERBOSE

case ENV['COVERAGE']
when 'deep'
  ENV['DEEP_COVER'] = 'true'
  require 'deep_cover'
when 'true'
  require 'deep_cover/builtin_takeover'
  require 'simplecov'
end

require 'asciidoctor/pdf'
require 'base64'
require 'fileutils'
require 'pathname'
require_relative 'spec_helper/ext'
require_relative 'spec_helper/helpers'
require_relative 'spec_helper/inspectors'
require_relative 'spec_helper/matchers'

RSpec.configure do |config|
  config.extend RSpec::ExampleGroupHelpers
  config.include RSpec::ExampleHelpers

  helpers = Object.new.extend RSpec::ExampleHelpers

  config.before :suite do
    (Pathname.new helpers.output_dir).tap {|dir| dir.rmtree secure: true }.mkdir
    (Pathname.new helpers.tmp_dir).tap {|dir| dir.rmtree secure: true }.mkdir
  end

  config.after :suite do
    (Pathname.new helpers.output_dir).rmtree secure: true unless (ENV.key? 'DEBUG') || config.reporter.failed_examples.any? {|it| it.metadata[:visual] }
    (Pathname.new helpers.tmp_dir).rmtree secure: true
  end
end