Sha256: b4a35c33363253cc309b4ea7d0b402963a546e19ad1d4ddcb24ee8d1c29588a4
Contents?: true
Size: 1.94 KB
Versions: 2
Compression:
Stored size: 1.94 KB
Contents
require 'spec_helper' describe ActiveRemote::Serializers::Protobuf::Fields do describe ".from_attributes" do let(:ready_value) { { :records => [ { :name => 'Cool Post', :errors => [ { :message => 'Boom!' } ] } ] } } let(:value) { { :records => { :name => 'Cool Post', :errors => { :message => 'Boom!' } } } } it "gets protobuf-ready fields from attributes" do described_class.from_attributes(Generic::Remote::Posts, value).should eq ready_value end end end describe ActiveRemote::Serializers::Protobuf::Field do describe ".from_attribute" do context "when field is a repeated message" do let(:field) { Generic::Remote::Posts.get_field(:records) } context "and the value is not an array" do let(:ready_value) { [ { :name => 'Cool Post', :errors => [ { :message => 'Boom!' } ] } ] } let(:value) { { :name => 'Cool Post', :errors => { :message => 'Boom!' } } } it "gets protobuf-ready fields from the value" do described_class.from_attribute(field, value).should eq ready_value end end end context "when field is a message" do let(:field) { Generic::Remote::Post.get_field(:category) } context "and value is a hash" do let(:ready_value) { { :name => 'Film', :errors => [ { :message => 'Boom!' } ] } } let(:value) { { :name => 'Film', :errors => { :message => 'Boom!' } } } it "gets protobuf-ready fields from the value" do described_class.from_attribute(field, value).should eq ready_value end end end context "when field is repeated" do let(:field) { Generic::Remote::PostRequest.get_field(:name) } context "and the value is not an array" do let(:ready_value) { [ 'Cool Post' ] } let(:value) { 'Cool Post' } it "gets protobuf-ready fields from the value" do described_class.from_attribute(field, value).should eq ready_value end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_remote-2.0.0 | spec/lib/active_remote/serializers/protobuf_spec.rb |
active_remote-2.0.0.rc2 | spec/lib/active_remote/serializers/protobuf_spec.rb |