Sha256: f6763c564a075c6a93091cf91c0f84157499ed477024502e1bc1de5f5a93af1e

Contents?: true

Size: 959 Bytes

Versions: 1

Compression:

Stored size: 959 Bytes

Contents

require_relative '../spec_helper'
require 'common_repository_model/area'
require 'common_repository_model/collection'

describe CommonRepositoryModel::Area do

  subject { CommonRepositoryModel::Area.new(area_name: area_name) }
  let(:area_name) { 'My Area Name'}

  it 'should have #area_name' do
    subject.area_name.must_equal area_name
  end

  describe 'has_many #collections' do
    it 'should build #collections' do
      subject.collections.build.
        must_be_kind_of(CommonRepositoryModel::Collection)
    end
  end

  describe 'integration' do
    let(:collection) { CommonRepositoryModel::Collection.new }
    it 'should save' do
      # Before we can add a collection, the containing object
      # must be saved
      subject.save.must_equal true
      subject.collections << collection
      subject.save.must_equal true
      new_subject = subject.class.find(subject.pid)

      new_subject.collections.size.must_equal 1
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
common_repository_model-0.0.1 spec/common_respository_model/area_spec.rb