Skip to content

Instantly share code, notes, and snippets.

@twillis
Created May 12, 2016 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twillis/99b34cf02d56c05baa34e9f672672a0f to your computer and use it in GitHub Desktop.
Save twillis/99b34cf02d56c05baa34e9f672672a0f to your computer and use it in GitHub Desktop.
require 'spec_helper'
RSpec.describe 'Dry::Validation.Schema' do
let(:result) do
schema.call(params)
end
context 'schema is array of nested attributes' do
let(:schema) do
Dry::Validation.Schema do
key(:data).required do
each do
schema do
key(:a).required(:int?)
key(:b).required(:int?)
end
end
end
end
end
context 'inavlid data' do
let(:params) do
{data: []}
end
it 'invalid' do
expect(result.success?).to be false
puts result.messages
end
end
context 'invalid data' do
let(:params) do
{data: [{a: 1, c: 2}]}
end
it 'invalid' do
puts result.messages
expect(result.success?).to be false # currently fails
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment