Sha256: 7ea786f3e57d3778c101055ef2602faeba5c3003faaa8d99c73abcde85252ef9
Contents?: true
Size: 934 Bytes
Versions: 1
Compression:
Stored size: 934 Bytes
Contents
require 'ostruct' RSpec.describe Schema, 'defining schema with attrs' do subject(:validation) { schema.new } let(:schema) do Class.new(Dry::Validation::Schema) do attr(:email) { |email| email.filled? } attr(:address) do |address| address.attr(:city, &:filled?) address.attr(:street, &:filled?) end end end describe '#call' do context 'when valid input' do let(:input) do struct_from_hash(email: "email@test.com", address: { city: 'NYC', street: 'Street 1/2' }) end it 'should be valid' do expect(validation.(input)).to be_empty end end context 'when input does not have proper attributes' do let(:input) do struct_from_hash(name: "John", address: { country: 'US', street: 'Street 1/2' }) end it 'should not be valid' do expect(validation.(input)).to_not be_empty end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry-validation-0.6.0 | spec/integration/schema/attrs_spec.rb |