deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Lutterkort <lut...@redhat.com>
Subject Re: [PATCH core 1/4] CIMI: Added helper methods to check serialization and inconsistencies between JSON and XML
Date Tue, 22 Nov 2011 00:58:15 GMT
On Wed, 2011-11-16 at 21:34 +0100, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mfojtik@redhat.com>
> 
> ---
>  server/spec/spec_helper.rb |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/server/spec/spec_helper.rb b/server/spec/spec_helper.rb
> index d046260..c8b41fc 100644
> --- a/server/spec/spec_helper.rb
> +++ b/server/spec/spec_helper.rb
> @@ -90,6 +90,16 @@ class HashCmp
>    end
>  end
>  
> +def should_serialize_from_xml!(model, xml, json)
> +  model.to_xml.should serialize_to xml, :fmt => :xml
> +  model.to_json.should serialize_to json, :fmt => :json
> +end
> +
> +def should_serialize_from_json!(model, xml, json)
> +  model.to_xml.should serialize_to xml, :fmt => :xml
> +  model.to_json.should serialize_to json, :fmt => :json
> +end

Aren't these two methods doing exactly the same ? What I had in mind was

        def check_serialization(model_class, xml, json)
          # Roundtrip in same format
          model_class.from_xml(xml).should serialize_to xml, :fmt
        => :xml
          model_class.from_json(json).should serialize_to json, :fmt => :json
          # Roundtrip crossing format
          model_class.from_xml(xml).should serialize_to json, :fmt
        => :json
          model_class.from_json(json).should serialize_to xml, :fmt
        => :xml
        end

David



Mime
View raw message