<commit_before>require 'lurker/spy'

if defined?(RSpec) && RSpec.respond_to?(:configure)
  RSpec.configure do |config|

    lurker = ->(example) {
      # RSpec::Core::ExampleGroup::Nested_1 === self
      @_example = example

      if (metadata = example.metadata[:lurker]).present?
        Lurker::Spy.on(suffix: metadata, &example)
      else
        example.call
      end
    }

    config.around(:each, type: :controller, &lurker)
    config.around(:each, type: :request, &lurker)

    unless RSpec::Core::Version::STRING > '3'
      config.treat_symbols_as_metadata_keys_with_true_values = true
    end
  end
end<commit_msg>changed hook detection in rspec<commit_after>require 'lurker/spy'

if defined?(RSpec) && RSpec.respond_to?(:configure)
  when_tagged_with_lurker = { :lurker => lambda { |v| !!v } }

  RSpec.configure do |config|
    config.around(:each, when_tagged_with_lurker) do |ex|
      example = ex.respond_to?(:metadata) ? ex : ex.example
      options = example.metadata[:lurker]
      options = if options.is_a?(Hash)
        options.dup
      elsif options.is_a?(String)
        { suffix: options }
      else
        {}
      end
      Lurker::Spy.on(options, &example)
    end

    unless RSpec::Core::Version::STRING > '3'
      config.treat_symbols_as_metadata_keys_with_true_values = true
    end
  end
end
{'fraction_non_alphanumeric': 0.12724550898203593, 'fraction_numerical': 0.002245508982035928, 'mean_word_length': 3.2044025157232703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5502174', 'n_tokens_mistral': 462, 'n_tokens_neox': 455, 'n_words': 86}