ENV["RAILS_ENV"] = "test"
ENV["GOVUK_APP_DOMAIN"] = "test.gov.uk"

require File.expand_path("../config/environment", __dir__)

if ENV["TEST_COVERAGE"]
  require "simplecov"
  require "simplecov-rcov"

  SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
  SimpleCov.start "rails"
end

FLOW_REGISTRY_OPTIONS[:preload_flows] = true

require "rails/test_help"

require "mocha/setup"
Mocha::Configuration.prevent(:stubbing_non_existent_method)

require "webmock/minitest"
WebMock.disable_net_connect!(allow_localhost: true)

module MinitestWithTeardownCustomisations
  def teardown
    super
    Timecop.return
    WorldLocation.reset_cache
  end
end
Minitest::Test.prepend MinitestWithTeardownCustomisations

require "gds_api/test_helpers/json_client_helper"
require_relative "support/fixture_methods"
require_relative "support/world_location_stubbing_methods"

class ActiveSupport::TestCase
  include FixtureMethods
  include WorldLocationStubbingMethods
end

require "slimmer/test"
require "govuk-content-schema-test-helpers/test_unit"

GovukContentSchemaTestHelpers.configure do |config|
  config.schema_type = "publisher_v2"
  config.project_root = Rails.root
end

ENV["RAILS_ENV"] = "test"
ENV["GOVUK_APP_DOMAIN"] = "test.gov.uk"

require File.expand_path("../config/environment", __dir__)

if ENV["TEST_COVERAGE"]
  require "simplecov"
  require "simplecov-rcov"

  SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
  SimpleCov.start "rails"
end

FLOW_REGISTRY_OPTIONS[:preload_flows] = true

require "rails/test_help"

require "mocha/minitest"
Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }

require "webmock/minitest"
WebMock.disable_net_connect!(allow_localhost: true)

module MinitestWithTeardownCustomisations
  def teardown
    super
    Timecop.return
    WorldLocation.reset_cache
  end
end
Minitest::Test.prepend MinitestWithTeardownCustomisations

require "gds_api/test_helpers/json_client_helper"
require_relative "support/fixture_methods"
require_relative "support/world_location_stubbing_methods"

class ActiveSupport::TestCase
  include FixtureMethods
  include WorldLocationStubbingMethods
end

require "slimmer/test"
require "govuk-content-schema-test-helpers/test_unit"

GovukContentSchemaTestHelpers.configure do |config|
  config.schema_type = "publisher_v2"
  config.project_root = Rails.root
end

Configure Mocha in a better way
Configure Mocha in a better way

This should fix some deprecation warnings:

```
Mocha deprecation warning at /var/lib/jenkins/bundles/ruby/2.6.0/gems/activesupport-5.2.2.1/lib/active_support/dependencies.rb:291:in `require': Require 'mocha/test_unit', 'mocha/minitest' or 'mocha/api' instead of 'mocha/setup'.
Mocha deprecation warning at /var/lib/jenkins/workspace/nt-finance-dependants-allowances/test/test_helper.rb:19:in `<top (required)>': Use Mocha.configure { |c| c.stubbing_non_existent_method = :prevent }
```
