Sha256: 446dcb31558c09cfdf62f931def4a190ec69bfbf7c642da90952959e83b17933

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

require "spec_helper"

describe Mongoid::NestedSerialization::Serializer do
  let(:serialized) do
    Mongoid::NestedSerialization::Serializer.new(object).to_hash
  end
  let(:account) { Mongoid::NestedSerialization::Test::Account.create }
  let(:item) { account.items.create }
  let(:photo) { item.photos.create }

  describe "#to_hash" do
    context "given a top-level object" do
      let(:object) { account }
      
      it "should not have embedded data" do
        expect(serialized.has_key?(:embedded)).to be_false
      end
    end
    
    context "given a second-level object" do
      let(:object) { item }
      
      it "should have embedded data" do
        expect(serialized.has_key?(:embedded)).to be_true
      end
      
      it "should not have double embedded data" do
        expect(serialized[:embedded].has_key?(:embedded)).to be_false
      end
    end
    
    context "given a third-level object" do
      let(:object) { photo }
      
      it "should have embedded data" do
        expect(serialized.has_key?(:embedded)).to be_true
      end
      
      it "should have double embedded data" do
        expect(serialized[:embedded].has_key?(:embedded)).to be_true
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongoid-nested-serialization-0.0.6 spec/mongoid/nested_serialization/serializer_spec.rb
mongoid-nested-serialization-0.0.5 spec/mongoid/nested_serialization/serializer_spec.rb
mongoid-nested-serialization-0.0.4 spec/mongoid/nested_serialization/serializer_spec.rb
mongoid-nested-serialization-0.0.3 spec/mongoid/nested_serialization/serializer_spec.rb
mongoid-nested-serialization-0.0.2 spec/mongoid/nested_serialization/serializer_spec.rb
mongoid-nested-serialization-0.0.1 spec/mongoid/nested_serialization/serializer_spec.rb