Module: DaVinciPASTestKit::ValidationTest

Included in:
PasBundleValidation
Defined in:
lib/davinci_pas_test_kit/cross_suite/validation_test.rb

Instance Method Summary collapse

Instance Method Details

#perform_validation_test(resources, profile_url, profile_version, skip_if_empty: true) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/davinci_pas_test_kit/cross_suite/validation_test.rb', line 5

def perform_validation_test(resources,
                            profile_url,
                            profile_version,
                            skip_if_empty: true)
  skip_if skip_if_empty && resources.blank?,
          "No #{resource_type} resources conforming to the #{profile_url} profile were returned"

  omit_if resources.blank?,
          "No #{resource_type} resources provided so the #{profile_url} profile does not apply"

  profile_with_version = "#{profile_url}|#{profile_version}"
  resources.each do |resource|
    resource_is_valid?(resource:, profile_url: profile_with_version)
  end

  errors_found = messages.any? { |message| message[:type] == 'error' }

  assert !errors_found, "Resource does not conform to the profile #{profile_with_version}"
end