<commit_before>require 'simplecov'
require 'yaml'
require 'rspec'
require 'pry'
require_relative "../lib/rally_api"


#clear simplecov filters so this works in Rubymine
SimpleCov.adapters.delete(:root_filter)
SimpleCov.filters.clear
SimpleCov.start do
  add_filter '/test/'
  add_filter '/.rvm/'
end


# --- For spec helper - include a file named RallyAPIcredentials.txt in this directory and put this in it
#     put in your URL, user, password and workspace/project and the tests will run against those endpoints when needed
#     why no mocking?  I dont' always trust we get what we want from the wsapi, this helps get some confidence things
#     really are working as they should
#RallyURL:  https://trial.rallydev.com/slm
#Username:  <EMAIL>
#Password:  password
#Workspace: Workspace Name
#Project:   Project Name
#Debug:     false
#NonDefaultWS:  NonDefaultWorkspace
#CustomPIType:  CustomType
#WebLinkFieldName: CustomField

# TODO: Deprecate in favor of new RallyConfigLoader class and load_api_config helper method
module RallyAPISpecHelper
  path = ""
  #cred_file = "RallyAPIcredentialsAPIKEY.txt"
  cred_file = "RallyAPIcredentials.txt"

  if (Dir.pwd.include?("test"))
    path = "./#{cred_file}"
  else
    path = "./test/#{cred_file}"
  end
  config = YAML.load_file(path)

  TEST_SETUP = {}
  TEST_SETUP[:base_url]  = config["RallyURL"]
  TEST_SETUP[:username]  = config["Username"]
  TEST_SETUP[:password]  = config["Password"]
  TEST_SETUP[:api_key]   = config["API_KEY"]
  TEST_SETUP[:workspace] = config["Workspace"]
  TEST_SETUP[:project]   = config["Project"]
  TEST_SETUP[:debug]     = config["Debug"]
  TEST_SETUP[:version]   = config["Version"]

  EXTRA_SETUP = {}
  EXTRA_SETUP[:nondefault_ws]  = config["NonDefaultWS"]
  EXTRA_SETUP[:custom_pi_type] = config["CustomPIType"]
  EXTRA_SETUP[:weblink_field_name] = config["WebLinkFieldName"]

end


### RallyConfigLoader::LoadConfig enables dynamic loading of config files
# Usage: Load Config File from spec
#   load config from default file: load_api_config.test_setup
#   load config from custom file:  load_api_config('YourConfigFile.txt').test_setup
module RallyConfigLoader
  class LoadConfig
    attr_accessor :test_setup, :extra_setup

    def initialize(config_file = 'RallyAPIcredentials.txt')
      @cred_file = config_file

      if (Dir.pwd.include?("test"))
        path = "./#{@cred_file}"
      else
        path = "./test/#{@cred_file}"
      end
      config_file = YAML.load_file(path)
      
      @extra_setup = {}
      @extra_setup[:nondefault_ws]  = config_file["NonDefaultWS"]
      @extra_setup[:custom_pi_type] = config_file["CustomPIType"]
      @extra_setup[:weblink_field_name] = config_file["WebLinkFieldName"]

      @test_setup = {}
      @test_setup[:base_url]  = config_file["RallyURL"]
      @test_setup[:username]  = config_file["Username"]
      @test_setup[:password]  = config_file["Password"]
      @test_setup[:api_key]   = config_file["API_KEY"]
      @test_setup[:workspace] = config_file["Workspace"]
      @test_setup[:project]   = config_file["Project"]
      @test_setup[:debug]     = config_file["Debug"]
      @test_setup[:version]   = config_file["Version"]
    end

  end

  def load_api_config(config_file = 'RallyAPIcredentials.txt')
    LoadConfig.new(config_file)
  end
end

RSpec.configure do |c|
  c.include(RallyConfigLoader)
end<commit_msg>S73896- colorize and format test output<commit_after>require 'simplecov'
require 'yaml'
require 'rspec'
require 'pry'
require_relative "../lib/rally_api"


#clear simplecov filters so this works in Rubymine
SimpleCov.adapters.delete(:root_filter)
SimpleCov.filters.clear
SimpleCov.start do
  add_filter '/test/'
  add_filter '/.rvm/'
end


# --- For spec helper - include a file named RallyAPIcredentials.txt in this directory and put this in it
#     put in your URL, user, password and workspace/project and the tests will run against those endpoints when needed
#     why no mocking?  I dont' always trust we get what we want from the wsapi, this helps get some confidence things
#     really are working as they should
#RallyURL:  https://trial.rallydev.com/slm
#Username:  <EMAIL>
#Password:  password
#Workspace: Workspace Name
#Project:   Project Name
#Debug:     false
#NonDefaultWS:  NonDefaultWorkspace
#CustomPIType:  CustomType
#WebLinkFieldName: CustomField

# TODO: Deprecate in favor of new RallyConfigLoader class and load_api_config helper method
module RallyAPISpecHelper
  path = ""
  #cred_file = "RallyAPIcredentialsAPIKEY.txt"
  cred_file = "RallyAPIcredentials.txt"

  if (Dir.pwd.include?("test"))
    path = "./#{cred_file}"
  else
    path = "./test/#{cred_file}"
  end
  config = YAML.load_file(path)

  TEST_SETUP = {}
  TEST_SETUP[:base_url]  = config["RallyURL"]
  TEST_SETUP[:username]  = config["Username"]
  TEST_SETUP[:password]  = config["Password"]
  TEST_SETUP[:api_key]   = config["API_KEY"]
  TEST_SETUP[:workspace] = config["Workspace"]
  TEST_SETUP[:project]   = config["Project"]
  TEST_SETUP[:debug]     = config["Debug"]
  TEST_SETUP[:version]   = config["Version"]

  EXTRA_SETUP = {}
  EXTRA_SETUP[:nondefault_ws]  = config["NonDefaultWS"]
  EXTRA_SETUP[:custom_pi_type] = config["CustomPIType"]
  EXTRA_SETUP[:weblink_field_name] = config["WebLinkFieldName"]

end


### RallyConfigLoader::LoadConfig enables dynamic loading of config files
# Usage: Load Config File from spec
#   load config from default file: load_api_config.test_setup
#   load config from custom file:  load_api_config('YourConfigFile.txt').test_setup
module RallyConfigLoader
  class LoadConfig
    attr_accessor :test_setup, :extra_setup

    def initialize(config_file = 'RallyAPIcredentials.txt')
      @cred_file = config_file

      if (Dir.pwd.include?("test"))
        path = "./#{@cred_file}"
      else
        path = "./test/#{@cred_file}"
      end
      config_file = YAML.load_file(path)
      
      @extra_setup = {}
      @extra_setup[:nondefault_ws]  = config_file["NonDefaultWS"]
      @extra_setup[:custom_pi_type] = config_file["CustomPIType"]
      @extra_setup[:weblink_field_name] = config_file["WebLinkFieldName"]

      @test_setup = {}
      @test_setup[:base_url]  = config_file["RallyURL"]
      @test_setup[:username]  = config_file["Username"]
      @test_setup[:password]  = config_file["Password"]
      @test_setup[:api_key]   = config_file["API_KEY"]
      @test_setup[:workspace] = config_file["Workspace"]
      @test_setup[:project]   = config_file["Project"]
      @test_setup[:debug]     = config_file["Debug"]
      @test_setup[:version]   = config_file["Version"]
    end

  end

  def load_api_config(config_file = 'RallyAPIcredentials.txt')
    LoadConfig.new(config_file)
  end
end

RSpec.configure do |c|
  c.include(RallyConfigLoader)
  c.tty = true
  c.color = true
  c.formatter = :documentation
end
{'fraction_non_alphanumeric': 0.11723432246747552, 'fraction_numerical': 0.000730887297178775, 'mean_word_length': 4.299767621998451, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1052413', 'n_tokens_mistral': 2267, 'n_tokens_neox': 2242, 'n_words': 502}