Sha256: 2e3f615cf0fcf677045d1b34ccf0a9bdc17b43ce7fdbfcafa734cd81fd79d4e9

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

try_spec do

  require './spec/fixtures/person'

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

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

      describe 'when dumped and loaded again' do
        before :all do
          @resource.save.should be_true
          @resource.reload
        end

        it 'has nil positions list' do
          @resource.positions.should be_nil
        end
      end
    end

    describe 'with a few items on the positions list' do
      before :all 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 :all do
          @resource.save.should be_true
          @resource.reload
        end

        it 'loads positions list to the state when it was dumped/persisted with keys being strings' do
          @resource.positions.should == [
            { '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 :all do
        @resource.positions = []
      end

      describe 'when dumped and loaded again' do
        before :all do
          @resource.save.should be_true
          @resource.reload
        end

        it 'has empty positions list' do
          @resource.positions.should == []
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-types-0.10.2 spec/integration/json_spec.rb