<commit_before>module PavlovSupport
  # TODO why is this in pavlov support, this should be put in some general
  # support file or spec_helper.
  def stub_classes *classnames
    classnames.each do |classname|
      stub_const classname, Class.new
    end
  end

  def expect_validating hash
    hash[:pavlov_options] ||= {}
    hash[:pavlov_options][:ability] = mock(can?: true)
    expect {described_class.new(hash).call}
  end

  def fail_validation message
    raise_error(Pavlov::ValidationError, message)
  end

  class ExecuteAsUser < Struct.new(:user)
    include Pavlov::Helpers

    def pavlov_options
      Util::PavlovContextSerialization.pavlov_context_by_user user
    end

    def execute &block
      yield self
    end<commit_msg>Allow overriding stubbed can?<commit_after>module PavlovSupport
  # TODO why is this in pavlov support, this should be put in some general
  # support file or spec_helper.
  def stub_classes *classnames
    classnames.each do |classname|
      stub_const classname, Class.new
    end
  end

  def expect_validating hash, ability_can=true
    hash[:pavlov_options] ||= {}
    hash[:pavlov_options][:ability] = mock(can?: ability_can)
    expect {described_class.new(hash).call}
  end

  def fail_validation message
    raise_error(Pavlov::ValidationError, message)
  end

  class ExecuteAsUser < Struct.new(:user)
    include Pavlov::Helpers

    def pavlov_options
      Util::PavlovContextSerialization.pavlov_context_by_user user
    end

    def execute &block
      yield self
    end
{'fraction_non_alphanumeric': 0.07231270358306188, 'fraction_numerical': 0.0, 'mean_word_length': 3.726153846153846, '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': '1774653', 'n_tokens_mistral': 482, 'n_tokens_neox': 469, 'n_words': 129}