<commit_before>module RSpec
  module Mocks
    class HaveReceived
      COUNT_CONSTRAINTS = %w(exactly at_least at_most times once twice)
      ARGS_CONSTRAINTS = %w(with)
      CONSTRAINTS = COUNT_CONSTRAINTS + ARGS_CONSTRAINTS

      def initialize(method_name)
        @method_name = method_name
        @constraints = []
      end

      def matches?(subject)
        @subject = subject
        @expectation = expect
        @expectation.expected_messages_received?
      end

      def does_not_match?(subject)
        @subject = subject
        ensure_count_unconstrained
        @expectation = expect.never
        @expectation.expected_messages_received?
      end

      def failure_message
        generate_failure_message
      end

      def negative_failure_message
        generate_failure_message
      end

      CONSTRAINTS.each do |expectation|
        define_method expectation do |*args|
          @constraints << [expectation, *args]
          self
        end
      end

      private

      def expect
        build_expectation do |expectation|
          apply_constraints_to expectation
        end
      end

      def apply_constraints_to(expectation)
        @constraints.each do |constraint|
          expectation.send(*constraint)
        end
      end

      def ensure_count_unconstrained
        if count_constrait
          raise RSpec::Mocks::MockExpectationError,
            "can't use #{count_constrait} when negative"
        end
      end

      def count_constrait
        @constraints.map(&:first).detect do |constraint|
          COUNT_CONSTRAINTS.include?(constraint)
        end
      end

      def generate_failure_message
        mock_proxy.check_for_unexpected_arguments(@expectation)
        @expectation.generate_error
      rescue RSpec::Mocks::MockExpectationError => error
        error.message
      end

      def build_expectation(&block)
        mock_proxy.build_expectation(@method_name, &block)
      end

      def mock_proxy
        RSpec::Mocks.proxy_for(@subject)
      end
    end
  end
end<commit_msg>Fix typo: constrait => constraint<commit_after>module RSpec
  module Mocks
    class HaveReceived
      COUNT_CONSTRAINTS = %w(exactly at_least at_most times once twice)
      ARGS_CONSTRAINTS = %w(with)
      CONSTRAINTS = COUNT_CONSTRAINTS + ARGS_CONSTRAINTS

      def initialize(method_name)
        @method_name = method_name
        @constraints = []
      end

      def matches?(subject)
        @subject = subject
        @expectation = expect
        @expectation.expected_messages_received?
      end

      def does_not_match?(subject)
        @subject = subject
        ensure_count_unconstrained
        @expectation = expect.never
        @expectation.expected_messages_received?
      end

      def failure_message
        generate_failure_message
      end

      def negative_failure_message
        generate_failure_message
      end

      CONSTRAINTS.each do |expectation|
        define_method expectation do |*args|
          @constraints << [expectation, *args]
          self
        end
      end

      private

      def expect
        build_expectation do |expectation|
          apply_constraints_to expectation
        end
      end

      def apply_constraints_to(expectation)
        @constraints.each do |constraint|
          expectation.send(*constraint)
        end
      end

      def ensure_count_unconstrained
        if count_constraint
          raise RSpec::Mocks::MockExpectationError,
            "can't use #{count_constraint} when negative"
        end
      end

      def count_constraint
        @constraints.map(&:first).detect do |constraint|
          COUNT_CONSTRAINTS.include?(constraint)
        end
      end

      def generate_failure_message
        mock_proxy.check_for_unexpected_arguments(@expectation)
        @expectation.generate_error
      rescue RSpec::Mocks::MockExpectationError => error
        error.message
      end

      def build_expectation(&block)
        mock_proxy.build_expectation(@method_name, &block)
      end

      def mock_proxy
        RSpec::Mocks.proxy_for(@subject)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.058002406738868834, 'fraction_numerical': 0.0, 'mean_word_length': 2.234241245136187, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '1860955', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1128, 'n_words': 246}