diff --git a/lib/prismic/json_parsers.rb b/lib/prismic/json_parsers.rb index 5c90aee..642f40b 100644 --- a/lib/prismic/json_parsers.rb +++ b/lib/prismic/json_parsers.rb @@ -36,7 +36,7 @@ def integration_fields_parser(json) Prismic::Fragments::IntegrationField.new(json['value']) end - def boolean_field_parser(json) + def boolean_field_parser(json) Prismic::Fragments::BooleanField.new(json['value']) end @@ -84,7 +84,7 @@ def text_parser(json) Prismic::Fragments::Text.new(json['value']) end - def separator_parser(json) + def separator_parser(_) Prismic::Fragments::Separator.new('') end @@ -97,6 +97,8 @@ def web_link_parser(json) end def date_parser(json) + return Prismic::Fragments::Text.new('') if json['value'].empty? + Prismic::Fragments::Date.new(Time.parse(json['value'])) end diff --git a/spec/json_parsers_spec.rb b/spec/json_parsers_spec.rb index f985141..51e5d3c 100644 --- a/spec/json_parsers_spec.rb +++ b/spec/json_parsers_spec.rb @@ -69,19 +69,38 @@ end describe 'date_parser' do - before do - raw_json = <