Module: ActiveFedora::TestSupport

Defined in:
lib/active_fedora/test_support.rb

Instance Method Summary collapse

Instance Method Details

#assert_active_fedora_belongs_to(subject, association_name, object) ⇒ Object

Assert that the :subject’s :association_name equals the input :object



26
27
28
# File 'lib/active_fedora/test_support.rb', line 26

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

#assert_active_fedora_has_many(subject, association_name, objects) ⇒ Object

Assert that the :subject’s :association_name contains all of the :objects



31
32
33
34
35
36
37
# File 'lib/active_fedora/test_support.rb', line 31

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

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

Assert that all of the :objects are persisted the :subject’s RELS-EXT entry with the :predicate.



7
8
9
10
11
12
13
14
# File 'lib/active_fedora/test_support.rb', line 7

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

#assert_rels_ext_has_model(subject, class_name) ⇒ Object

Assert that the :subject’s RELS-EXT for predicate :has_model collection includes the class_name



18
19
20
21
22
23
# File 'lib/active_fedora/test_support.rb', line 18

def assert_rels_ext_has_model(subject, class_name)
  model_relationships = subject.relationships(:has_model)
  assert_block("Expected afmodel:#{class_name} to be defined in #{model_relationships.inspect}") do
    model_relationships.detect {|r| r =~ /\/afmodel:#{class_name}\Z/ }
  end
end