<commit_before>require 'test_helper'

Order = Struct.new(:trusted, :card_number)

class OrderValidator < Allowing::Validator
  validates :card_number,
            format: /^d+$/,
            unless: proc { |order| order.trusted },
            allow_nil: true
end

module Allowing
  module IntegrationTests
    class ValidationsWithOptionsTest < Minitest::Test
      def setup
        @subject   = Order.new(true, 'abc')
        @validator = OrderValidator.new
      end

      def test_validate_returns_no_errors_if_unless_conditions_is_not_met
        assert @validator.call(@subject).empty?
      end

      def test_validate_returns_no_error_if_unless_conditions_is_met
        @subject.trusted = false

        refute @validator.call(@subject).empty?
      end

      def test_validate_returns_no_errors_if_nil_value_is_given
        @subject.trusted     = false
        @subject.card_number = nil

        assert @validator.call(@subject).empty?
      end
    end
  end
end<commit_msg>Fix wrong test name<commit_after>require 'test_helper'

Order = Struct.new(:trusted, :card_number)

class OrderValidator < Allowing::Validator
  validates :card_number,
            format: /^d+$/,
            unless: proc { |order| order.trusted },
            allow_nil: true
end

module Allowing
  module IntegrationTests
    class ValidationsWithOptionsTest < Minitest::Test
      def setup
        @subject   = Order.new(true, 'abc')
        @validator = OrderValidator.new
      end

      def test_validate_returns_no_errors_if_unless_conditions_is_not_met
        assert @validator.call(@subject).empty?
      end

      def test_validate_returns_a_error_if_unless_conditions_is_met
        @subject.trusted = false

        refute @validator.call(@subject).empty?
      end

      def test_validate_returns_no_errors_if_nil_value_is_given
        @subject.trusted     = false
        @subject.card_number = nil

        assert @validator.call(@subject).empty?
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0765743073047859, 'fraction_numerical': 0.0, 'mean_word_length': 2.8192307692307694, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1783996', 'n_tokens_mistral': 598, 'n_tokens_neox': 585, 'n_words': 118}