Sha256: a24534ba2a44299a7448bcd0e2390026e99047c21c39c80d8d9f461fdf780169

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require 'spec_helper'

try_spec do

  require './spec/fixtures/person'

  describe Ardm::Fixtures::Person do
    before do
      @resource = Ardm::Fixtures::Person.new(:name => 'Thomas Edison')
    end

    describe 'with no positions information' do
      before do
        @resource.positions = nil
      end

      describe 'when dumped and loaded again' do
        before do
          expect(@resource.save).to be true
          @resource.reload
        end

        it 'has nil positions list' do
          expect(@resource.positions).to be_nil
        end
      end
    end

    describe 'with a few items on the positions list' do
      before do
        @resource.positions = [
          { :company => 'The Death Star, Inc', :title => 'Light sabre engineer'    },
          { :company => 'Sane Little Company', :title => 'Chief Curiosity Officer' },
        ]
      end

      describe 'when dumped and loaded again' do
        before do
          expect(@resource.save).to be true
          @resource.reload
        end

        it 'loads positions list to the state when it was dumped/persisted with keys being strings' do
          expect(@resource.positions).to eq([
            { 'company' => 'The Death Star, Inc',  'title' => 'Light sabre engineer'    },
            { 'company'  => 'Sane Little Company', 'title' => 'Chief Curiosity Officer' },
          ])
        end
      end
    end

    describe 'with positions information given as empty list' do
      before do
        @resource.positions = []
      end

      describe 'when dumped and loaded again' do
        before do
          expect(@resource.save).to be true
          @resource.reload
        end

        it 'has empty positions list' do
          expect(@resource.positions).to eq([])
        end
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ardm-0.1.0 spec/integration/json_spec.rb