diff --git a/spec/integration/schema/macros/hash_spec.rb b/spec/integration/schema/macros/hash_spec.rb index 83504c9bb..10728e665 100644 --- a/spec/integration/schema/macros/hash_spec.rb +++ b/spec/integration/schema/macros/hash_spec.rb @@ -98,6 +98,33 @@ end end + context "with custom coercible type" do + subject(:schema) do + ExpirationDate = Types::DateTime.constructor { |value| value.to_time.round.to_datetime } + Dry::Schema.Params do + required(:unnested_date).value(ExpirationDate) + required(:foo).hash do + required(:bar).hash do + required(:nested_date).value(ExpirationDate) + end + end + end + end + + let(:input) do + { + foo: {bar: {nested_date: "2021-11-11T00:00:00+00:00"}}, + unnested_date: "2021-11-11T00:00:00+00:00" + } + end + + xspecify do + pending + expect(result).to be_successful + expect(result.to_h).to eql(foo: {bar: {nested_date: DateTime.new(2021, 11, 11)}}, unnested_date: DateTime.new(2021, 11, 11)) + end + end + context "constrained type" do let(:hash_schema) do Types::Hash.schema({}).constrained([:filled])