Sha256: 5cb36d57fb733559d29ff1315aa2937b68830d91df28cd81cf8c352c00a15123

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'

try_spec do

  require './spec/fixtures/person'
  require './spec/fixtures/invention'

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

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

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

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

    describe 'with a few items on the inventions list' do
      before :all do
        @input = [ 'carbon telephone transmitter', 'light bulb', 'electric grid' ].map do |name|
          DataMapper::Types::Fixtures::Invention.new(name)
        end
        @resource.inventions = @input
      end

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

        it 'loads inventions list to the state when it was dumped/persisted with keys being strings' do
          @resource.inventions.should == @input
        end
      end
    end

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

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

        it 'has empty inventions list' do
          @resource.inventions.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/yaml_spec.rb