Module: LedgerSync::Test::Support

Defined in:
lib/ledger_sync/test/support.rb

Class Method Summary collapse

Class Method Details

.setup(*paths_to_require) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/ledger_sync/test/support.rb', line 30

def self.setup(*paths_to_require)
  # Dotenv
  require 'dotenv'
  Dotenv.load(
    '.env.test.local',
    '.env.test',
    '.env'
  )
  require 'climate_control'

  require 'webmock/rspec'
  require 'simplecov'
  require 'simplecov-lcov'
  require 'coveralls'

  SimpleCov::Formatter::LcovFormatter.config do |c|
    c.report_with_single_file = true
    c.single_report_path = 'coverage/lcov.info'
  end
  Coveralls.wear!('rails')

  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
    [
      Coveralls::SimpleCov::Formatter,
      SimpleCov::Formatter::HTMLFormatter,
      SimpleCov::Formatter::LcovFormatter
    ]
  )

  SimpleCov.start('rails') do
    add_filter 'lib/ledger_sync/util/debug.rb'
  end

  # Set an environment variable to determine when we are testing.  This
  # prevents things like the QuickBooks Online client overwriting
  # environment variables with dummy values.
  ENV['TEST_ENV'] = 'true'

  require 'bundler/setup'
  require 'ap'
  require 'byebug'

  paths_to_require.each { |e| require e.to_s }

  core_support 'webmock_helpers'
  core_support 'record_collection'

  core_support 'qa/ledger_support_setup'

  core_support :factory_bot

  RSpec.configure do |config|
    # Enable flags like --only-failures and --next-failure
    config.example_status_persistence_file_path = 'tmp/rspec_history.txt'

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

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