Sha256: a3d201e096d1a06981dfbab75b3b547b8edfc0f766c8fa4dd36eab5f387fb438

Contents?: true

Size: 855 Bytes

Versions: 30

Compression:

Stored size: 855 Bytes

Contents

require 'spec_helper'

describe RestModel::Embeddable::Retriever do
  context "when it embeds one" do
    before do
      class ExampleChild < RestModel
        property :id
      end
    end

    let(:value) {{id: "7000"}}

    subject {RestModel::Embeddable.new(:example_child, many: false, start_key: "")}

    it "parses child" do
      child = subject.from_source(value)
      child.id.should == "7000"
    end
  end

  context "when it embeds many" do
    before do
      class ExampleChild < RestModel
        property :id
      end
    end

    let(:value) {{example_children: [{id: "7000"}, {id: "7001"}]}}

    subject {RestModel::Embeddable.new(:example_children, many: true)}

    it "parses children" do
      children = subject.from_source(value)
      children[0].id.should == "7000"
      children[1].id.should == "7001"
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rest_model-0.3.1 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.3.0 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.2.3 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.2.1 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.2.0 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.24 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.23 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.22 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.21 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.20 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.19 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.18 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.17 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.16 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.15 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.14 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.13 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.12 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.11 spec/unit/key/embeddable/retriever_spec.rb
rest_model-0.1.10 spec/unit/key/embeddable/retriever_spec.rb