Sha256: 43f43bc738f65026fac88e7b8e0837cf24731427a8a22ba21ada0027bfbaf1c7

Contents?: true

Size: 969 Bytes

Versions: 19

Compression:

Stored size: 969 Bytes

Contents

RSpec.describe Dry::Validation::Schema, 'dynamic predicate args' do
  context 'with base rules' do
    subject(:schema) do
      Dry::Validation.Schema do
        configure do
          def data
            %w(a b c)
          end
        end

        required(:letter).filled(included_in?: data)
      end
    end

    it 'evaluates predicate arguments' do
      expect(schema.(letter: 'a')).to be_success
      expect(schema.(letter: 'f')).to be_failure
    end
  end

  context 'with high-level rules' do
    subject(:schema) do
      Dry::Validation.Schema do
        configure do
          def data
            %w(a b c)
          end
        end

        required(:letter).filled(:str?)

        rule(valid_letter: [:letter]) do |letter|
          letter.included_in?(data)
        end
      end
    end

    it 'evaluates predicate arguments' do
      expect(schema.(letter: 'a')).to be_success
      expect(schema.(letter: 'f')).to be_failure
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
dry-validation-0.13.3 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.13.2 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.13.1 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.11.2 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.12.3 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.13.0 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.12.2 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.12.1 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.12.0 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.11.1 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.11.0 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.10.7 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.10.6 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.10.5 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.10.4 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.10.3 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.10.2 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.10.1 spec/integration/schema/dynamic_predicate_args_spec.rb
dry-validation-0.10.0 spec/integration/schema/dynamic_predicate_args_spec.rb