diff --git a/spec/fixtures/uscore311.tgz b/spec/fixtures/uscore311.tgz new file mode 100644 index 000000000..a9d256ca3 Binary files /dev/null and b/spec/fixtures/uscore311.tgz differ diff --git a/spec/inferno/dsl/ig_spec.rb b/spec/inferno/dsl/ig_spec.rb new file mode 100644 index 000000000..cc7b3b167 --- /dev/null +++ b/spec/inferno/dsl/ig_spec.rb @@ -0,0 +1,39 @@ +RSpec.describe Inferno::DSL::IG do + let(:uscore3_package) { File.expand_path('../../fixtures/uscore311.tgz', __dir__) } + + describe '#from_file' do + it 'loads an IG from file' do + ig = described_class.from_file(uscore3_package) + + # For each artifact type in the IG, check: + # the right number are loaded, + # they're all the expected type, + # and spot check a couple IDs + + # https://www.hl7.org/fhir/us/core/STU3.1.1/profiles.html + expect(ig.profiles.length).to eq(26) + expect(ig.profiles.map(&:resourceType).uniq).to eq(['StructureDefinition']) + expect(ig.profiles.map(&:id)).to include('us-core-patient', 'us-core-condition', + 'head-occipital-frontal-circumference-percentile') + + expect(ig.extensions.length).to eq(4) + expect(ig.extensions.map(&:resourceType).uniq).to eq(['StructureDefinition']) + expect(ig.extensions.map(&:type).uniq).to eq(['Extension']) + expect(ig.extensions.map(&:id)).to include('us-core-race', 'us-core-ethnicity') + + # https://www.hl7.org/fhir/us/core/STU3.1.1/terminology.html + expect(ig.value_sets.length).to eq(32) + expect(ig.value_sets.map(&:resourceType).uniq).to eq(['ValueSet']) + expect(ig.value_sets.map(&:id)).to include('us-core-usps-state', 'simple-language') + + # https://www.hl7.org/fhir/us/core/STU3.1.1/searchparameters.html + expect(ig.search_params.length).to eq(74) + expect(ig.search_params.map(&:resourceType).uniq).to eq(['SearchParameter']) + expect(ig.search_params.map(&:id)).to include('us-core-patient-name', 'us-core-encounter-id') + + # https://www.hl7.org/fhir/us/core/STU3.1.1/all-examples.html + expect(ig.examples.length).to eq(84) + expect(ig.examples.map(&:id)).to include('child-example', 'self-tylenol') + end + end +end diff --git a/spec/inferno/utils/ig_downloader_spec.rb b/spec/inferno/utils/ig_downloader_spec.rb index 2e77e33ae..dc0cfaee4 100644 --- a/spec/inferno/utils/ig_downloader_spec.rb +++ b/spec/inferno/utils/ig_downloader_spec.rb @@ -76,6 +76,16 @@ def with_temp_path(name) expect(File.read(temp_path)).to eq(package_binary) end end + + it 'successfully downloads package to custom path' do + stub_request(:get, 'https://packages.fhir.org/hl7.fhir.us.udap-security/-/hl7.fhir.us.udap-security-1.0.0.tgz') + .to_return(body: package_binary) + + with_temp_path('ig-downloader-canonical') do |temp_path| + ig_downloader.load_ig(canonical, nil, { verbose: false }, temp_path) + expect(File.read(temp_path)).to eq(package_binary) + end + end end end