<commit_before>require 'serverspec'
require 'net/ssh'
require 'vagrant_helper'
require 'yaml'
require 'pathname'
require 'rspec/its'

include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS

module RSpec
  module Core
    class ExampleGroup
      def get_file
        block = self.class.metadata[:block]
        block.source_location.first
      end
    end
  end
end

RSpec.configure do |c|

  debug = ENV['debug']
  keep_box = ENV['keep_box']
  box = ENV['box'] || 'wheezy'
  c.add_setting :before_files
  c.before_files = []
  root_dir = Dir.getwd
  vagrant_helper = VagrantHelper.new(root_dir, box, debug ? true : false)

  c.before :all do
    file = self.get_file
    unless c.before_files.include? file
      c.before_files.push file
      c.ssh.close if c.ssh

      vagrant_helper.reset unless keep_box
      c.ssh = vagrant_helper.connect
      spec_dir = Dir.new File.dirname file

      if File.exists? spec_dir.to_path + '/facts.json'
        vagrant_facts_path = vagrant_helper.get_path spec_dir.to_path + '/facts.json'
        vagrant_helper.execute_ssh("sudo mkdir -p /etc/facter/facts.d && sudo ln -sf #{vagrant_facts_path.shellescape} /etc/facter/facts.d/")
      end
<commit_msg>Always output vagrant box output in specs<commit_after>require 'serverspec'
require 'net/ssh'
require 'vagrant_helper'
require 'yaml'
require 'pathname'
require 'rspec/its'

include Serverspec::Helper::Ssh
include Serverspec::Helper::DetectOS

module RSpec
  module Core
    class ExampleGroup
      def get_file
        block = self.class.metadata[:block]
        block.source_location.first
      end
    end
  end
end

RSpec.configure do |c|

  debug = ENV['debug']
  keep_box = ENV['keep_box']
  box = ENV['box'] || 'wheezy'
  c.add_setting :before_files
  c.before_files = []
  root_dir = Dir.getwd
  vagrant_helper = VagrantHelper.new(root_dir, box, true)

  c.before :all do
    file = self.get_file
    unless c.before_files.include? file
      c.before_files.push file
      c.ssh.close if c.ssh

      vagrant_helper.reset unless keep_box
      c.ssh = vagrant_helper.connect
      spec_dir = Dir.new File.dirname file

      if File.exists? spec_dir.to_path + '/facts.json'
        vagrant_facts_path = vagrant_helper.get_path spec_dir.to_path + '/facts.json'
        vagrant_helper.execute_ssh("sudo mkdir -p /etc/facter/facts.d && sudo ln -sf #{vagrant_facts_path.shellescape} /etc/facter/facts.d/")
      end

{'fraction_non_alphanumeric': 0.10435497124075596, 'fraction_numerical': 0.0, 'mean_word_length': 3.24956369982548, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '70836', 'n_tokens_mistral': 880, 'n_tokens_neox': 849, 'n_words': 188}