Sha256: aeee1deac1b6ef11df1c8405a0fc4cc4f65cd4b614226bdb111343391a6a6ca0

Contents?: true

Size: 835 Bytes

Versions: 10

Compression:

Stored size: 835 Bytes

Contents

require 'spec_helper'

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

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

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

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

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

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

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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
transcriber-0.0.25 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.24 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.23 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.22 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.21 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.20 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.19 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.18 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.17 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.16 spec/unit/resource/parser/embeddable_spec.rb