<commit_before>require 'rspec'
require 'rspec/core/formatters/json_formatter'
require 'rspec/core/formatters/progress_formatter'

module Overcommit
  module Hook
    module PreCommit
      # run all specs before committing
      class Rspec < Base
        def run
          config = RSpec.configuration
          config.color = true

          json_formatter = RSpec::Core::Formatters::JsonFormatter.new(config.output)
          progress_formatter = RSpec::Core::Formatters::ProgressFormatter.new($stdout)

          reporter =  RSpec::Core::Reporter.new(json_formatter, progress_formatter)
          config.instance_variable_set(:@reporter, reporter)

          RSpec::Core::Runner.run(['spec'])

          :good if json_formatter.output_hash[:summary][:failure_count] == 0
        end
      end
    end
  end
end
<commit_msg>add fail_fast=true to rspec commit hook<commit_after>require 'rspec'
require 'rspec/core/formatters/json_formatter'
require 'rspec/core/formatters/progress_formatter'

module Overcommit
  module Hook
    module PreCommit
      # run all specs before committing
      class Rspec < Base
        def run
          config = RSpec.configuration
          config.color = true
          config.fail_fast = true

          json_formatter = RSpec::Core::Formatters::JsonFormatter.new(config.output)
          progress_formatter = RSpec::Core::Formatters::ProgressFormatter.new($stdout)

          reporter =  RSpec::Core::Reporter.new(json_formatter, progress_formatter)
          config.instance_variable_set(:@reporter, reporter)

          RSpec::Core::Runner.run(['spec'])

          :good if json_formatter.output_hash[:summary][:failure_count] == 0
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09393232205367562, 'fraction_numerical': 0.0011668611435239206, 'mean_word_length': 3.0833333333333335, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4414783', 'n_tokens_mistral': 496, 'n_tokens_neox': 471, 'n_words': 97}