Sha256: 80356d64a2009f96954875791bda0d37d76eb77b2e106766a5fba6d4f2574dc3

Contents?: true

Size: 800 Bytes

Versions: 6

Compression:

Stored size: 800 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)}

    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) {[{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

6 entries across 6 versions & 1 rubygems

Version Path
transcriber-0.0.15 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.14 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.13 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.12 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.11 spec/unit/resource/parser/embeddable_spec.rb
transcriber-0.0.10 spec/unit/resource/parser/embeddable_spec.rb