<commit_before>require 'simplecov'

SimpleCov.start do
  add_filter '/spec'
end if ENV["COVERAGE"]

require 'hashie'
require 'rubygems'
require 'bundler/setup'
require 'vcr'

require 'heirloom'

HEIRLOOM_INT_BP = ENV['HEIRLOOM_INTEGRATION_BUCKET_PREFIX']
RUN_INTEGRATION_TESTS = !HEIRLOOM_INT_BP.nil? && !HEIRLOOM_INT_BP.empty?

module SpecHelpers

  def mock_log
    mock 'log', :debug => true, :info => true, :warn => true, :error => true, :level= => true
  end

  def mock_config(args = {})
    args[:logger]          ||= mock_log
    args[:access_key]      ||= 'key'
    args[:secret_key]      ||= 'secret'
    args[:metadata_region] ||= 'us-west-1'
    args[:use_iam_profile] ||= false

    Hashie::Mash.new args
  end

  def integration_or_mock_config
    if RUN_INTEGRATION_TESTS && File.exists?("#{ENV['HOME']}/.heirloom.yml")
      begin
        Heirloom::Config.new(:environment => 'integration', :logger => mock_log)
      rescue SystemExit
        mock_config<commit_msg>simplify test in spec helper<commit_after>require 'simplecov'

SimpleCov.start do
  add_filter '/spec'
end if ENV["COVERAGE"]

require 'hashie'
require 'rubygems'
require 'bundler/setup'
require 'vcr'

require 'heirloom'

HEIRLOOM_INT_BP = ENV['HEIRLOOM_INTEGRATION_BUCKET_PREFIX']
RUN_INTEGRATION_TESTS = HEIRLOOM_INT_BP && !HEIRLOOM_INT_BP.empty?

module SpecHelpers

  def mock_log
    mock 'log', :debug => true, :info => true, :warn => true, :error => true, :level= => true
  end

  def mock_config(args = {})
    args[:logger]          ||= mock_log
    args[:access_key]      ||= 'key'
    args[:secret_key]      ||= 'secret'
    args[:metadata_region] ||= 'us-west-1'
    args[:use_iam_profile] ||= false

    Hashie::Mash.new args
  end

  def integration_or_mock_config
    if RUN_INTEGRATION_TESTS && File.exists?("#{ENV['HOME']}/.heirloom.yml")
      begin
        Heirloom::Config.new(:environment => 'integration', :logger => mock_log)
      rescue SystemExit
        mock_config
{'fraction_non_alphanumeric': 0.13924050632911392, 'fraction_numerical': 0.0010126582278481013, 'mean_word_length': 3.915422885572139, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6018513', 'n_tokens_mistral': 725, 'n_tokens_neox': 717, 'n_words': 141}