spec/integration/error_compiler_spec.rb in dry-validation-0.5.0 vs spec/integration/error_compiler_spec.rb in dry-validation-0.6.0

- old
+ new

@@ -7,10 +7,11 @@ let(:messages) do Messages.default.merge( en: { errors: { key?: '+%{name}+ key is missing in the hash', + attr?: 'Object does not respond to the +%{name}+ attr', rules: { address: { filled?: 'Please provide your address' } } @@ -21,18 +22,20 @@ describe '#call' do let(:ast) do [ [:error, [:input, [:name, nil, [[:key, [:name, [:predicate, [:key?, []]]]]]]]], + [:error, [:input, [:phone, nil, [[:attr, [:phone, [:predicate, [:attr?, []]]]]]]]], [:error, [:input, [:age, 18, [[:val, [:age, [:predicate, [:gt?, [18]]]]]]]]], [:error, [:input, [:email, "", [[:val, [:email, [:predicate, [:filled?, []]]]]]]]], [:error, [:input, [:address, "", [[:val, [:address, [:predicate, [:filled?, []]]]]]]]] ] end it 'converts error ast into another format' do expect(error_compiler.(ast)).to eql( name: [["+name+ key is missing in the hash"], nil], + phone: [["Object does not respond to the +phone+ attr"], nil], age: [["age must be greater than 18"], 18], email: [["email must be filled"], ''], address: [["Please provide your address"], ''] ) end