Module: CommonRepositoryModel::TestSupport

Defined in:
lib/common_repository_model/test_support.rb

Instance Method Summary collapse

Instance Method Details

#assert_active_fedora_belongs_to(subject, method_name, object) ⇒ Object



12
13
14
# File 'lib/common_repository_model/test_support.rb', line 12

def assert_active_fedora_belongs_to(subject, method_name, object)
  subject.send(method_name).must_equal object
end

#assert_active_fedora_has_many(subject, method_name, objects) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/common_repository_model/test_support.rb', line 16

def assert_active_fedora_has_many(subject, method_name, objects)
  association = subject.send(method_name)
  assert_equal objects.count, association.count
  objects.each do |object|
    assert association.include?(object)
  end
end

#assert_rels_ext(subject, predicate, objects = []) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/common_repository_model/test_support.rb', line 3

def assert_rels_ext(subject, predicate, objects = [])
  assert_equal objects.count, subject.relationships(predicate).count
  objects.each do |object|
    internal_uri = object.respond_to?(:internal_uri) ?
      object.internal_uri : object
    assert subject.relationships(predicate).include?(internal_uri)
  end
end

#with_persisted_area(name = nil, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/common_repository_model/test_support.rb', line 24

def with_persisted_area(name = nil, &block)
  options = {}
  options[:name] = name if name
  area = nil
  area = CommonRepositoryModel::Area.find_by_name(name) if name
  area ||= FactoryGirl.create(:common_repository_model_area, options)
  if block.arity == 1
    block.call(area)
  else
    block.call
  end
ensure
  area.delete if area
end