Sha256: 8f75cfb3cb7af1660e95130a5431b397155e3717d602dda94bf815a987528c83

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require_relative '../../../spec_helper'
require 'dm-core/support/subject_set'
require_relative 'shared/append_spec'

describe 'DataMapper::SubjectSet#<<' do
  before :all do

    class ::Person
      attr_reader :name
      attr_reader :hobby
      def initialize(name, hobby)
        @name  = name
        @hobby = hobby
      end
    end

  end

  before do
    @old_size  = set.size
    @old_index = set.entries.index(entry1)
  end

  subject { set << entry2 }

  let(:set)    { DataMapper::SubjectSet.new([ entry1 ]) }
  let(:entry1) { Person.new('snusnu', 'programming')    }
  let(:entry2) { Person.new('snusnu', 'tabletennis')    }

  context 'when appending a not yet included entry' do
    let(:entry2) { Person.new('Alice', 'cryptography') }

    it_behaves_like 'DataMapper::SubjectSet#<< when appending a not yet included entry'
  end

  context 'when updating an entry with the same cache key' do
    context 'and the new entry is already included' do
      let(:entry2) { entry1 }

      it_behaves_like 'DataMapper::SubjectSet#<< when updating an entry with the same cache key and the new entry is already included'
    end

    context 'and the new entry is not yet included' do
      it_behaves_like 'DataMapper::SubjectSet#<< when updating an entry with the same cache key and the new entry is not yet included'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sbf-dm-core-1.3.0 spec/unit/data_mapper/subject_set/append_spec.rb
sbf-dm-core-1.3.0.beta spec/unit/data_mapper/subject_set/append_spec.rb