<commit_before>module Shoulda # :nodoc:
  module Matchers
    module ActiveModel # :nodoc:

      # Ensures that the attribute can be set to the given value or values. If
      # multiple values are given the match succeeds only if all given values
      # are allowed. Otherwise, the matcher fails at the first bad value in the
      # argument list (the remaining arguments are not processed then).
      #
      # Options:
      # * <tt>with_message</tt> - value the test expects to find in
      #   <tt>errors.on(:attribute)</tt>. Regexp or string. If omitted,
      #   the test looks for any errors in <tt>errors.on(:attribute)</tt>.
      #
      # Example:
      #   it { should_not allow_value('bad').for(:isbn) }
      #   it { should allow_value("isbn 1 2345 6789 0").for(:isbn) }
      #
      def allow_value(*values)
        if values.empty?
          raise ArgumentError, "need at least one argument"
        else
          AllowValueMatcher.new(*values)
        end
      end

      class AllowValueMatcher # :nodoc:
        include Helpers

        def initialize(*values)
          @values_to_match = values
        end

        def for(attribute)
          @attribute = attribute
          self
        end

        def with_message(message)
          @expected_message = message
          self
        end

        def matches?(instance)
          @instance = instance
          @values_to_match.all? do |value|
            @value = value
            @instance.send("#{@attribute}=", @value)
            ! errors_match?
          end
        end

        def failure_message
          "Did not expect #{expectation}, got error: #{@matched_error}"
        end<commit_msg>Use #none? instead of inverting #all?<commit_after>module Shoulda # :nodoc:
  module Matchers
    module ActiveModel # :nodoc:

      # Ensures that the attribute can be set to the given value or values. If
      # multiple values are given the match succeeds only if all given values
      # are allowed. Otherwise, the matcher fails at the first bad value in the
      # argument list (the remaining arguments are not processed then).
      #
      # Options:
      # * <tt>with_message</tt> - value the test expects to find in
      #   <tt>errors.on(:attribute)</tt>. Regexp or string. If omitted,
      #   the test looks for any errors in <tt>errors.on(:attribute)</tt>.
      #
      # Example:
      #   it { should_not allow_value('bad').for(:isbn) }
      #   it { should allow_value("isbn 1 2345 6789 0").for(:isbn) }
      #
      def allow_value(*values)
        if values.empty?
          raise ArgumentError, "need at least one argument"
        else
          AllowValueMatcher.new(*values)
        end
      end

      class AllowValueMatcher # :nodoc:
        include Helpers

        def initialize(*values)
          @values_to_match = values
        end

        def for(attribute)
          @attribute = attribute
          self
        end

        def with_message(message)
          @expected_message = message
          self
        end

        def matches?(instance)
          @instance = instance
          @values_to_match.none? do |value|
            @value = value
            @instance.send("#{@attribute}=", @value)
            errors_match?
          end
        end

        def failure_message
          "Did not expect #{expectation}, got error: #{@matched_error}"
        end
{'fraction_non_alphanumeric': 0.08663729809104258, 'fraction_numerical': 0.005873715124816446, 'mean_word_length': 1.933677863910422, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6342536', 'n_tokens_mistral': 941, 'n_tokens_neox': 907, 'n_words': 306}