Sha256: 115cbc3b6f657aa4181a213e7c06d295972a640b602b0485c1400edc5778fbfe

Contents?: true

Size: 814 Bytes

Versions: 11

Compression:

Stored size: 814 Bytes

Contents

require 'spec_helper'

describe Restforce::Mash do
  describe '#build' do
    subject { described_class.build(input, nil) }

    context 'when array' do
      let(:input) { [{ foo: 'hello' }, { bar: 'world' }] }
      it 'mashifys each child object' do
        subject.each { |obj| obj.should be_a Restforce::Mash }
      end
    end
  end

  describe '#klass' do
    subject { described_class.klass(input) }

    context 'when the hash has a "records" key' do
      let(:input) { { 'records' => nil } }
      it { should eq Restforce::Collection }
    end

    context 'when the hash has an "attributes" key' do
      let(:input) { { 'attributes' => nil } }
      it { should eq Restforce::SObject }
    end

    context 'else' do
      let(:input) { {} }
      it { should eq Restforce::Mash }
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
restforce-0.1.4 spec/lib/mash_spec.rb
restforce-0.1.3 spec/lib/mash_spec.rb
restforce-0.1.2 spec/lib/mash_spec.rb
restforce-0.1.1 spec/lib/mash_spec.rb
restforce-0.1.0 spec/lib/mash_spec.rb
restforce-0.0.8 spec/lib/mash_spec.rb
restforce-0.0.7 spec/lib/mash_spec.rb
restforce-0.0.6 spec/lib/mash_spec.rb
restforce-0.0.5 spec/lib/mash_spec.rb
restforce-0.0.4 spec/lib/mash_spec.rb
restforce-0.0.3 spec/lib/mash_spec.rb