Skip to content

Commit

Permalink
update spec
Browse files Browse the repository at this point in the history
Signed-off-by: Vanessa Fotso <vfotso@mitre.org>
  • Loading branch information
vanessuniq committed Jan 21, 2025
1 parent c0b2c58 commit f01941c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
19 changes: 15 additions & 4 deletions spec/inferno/dsl/fhir_resource_validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,22 @@
.to_return(status: 200, body: invalid_outcome)
end

it 'includes resourceType/id in error message' do
result = validator.resource_is_valid?(resource2, profile_url, runnable)
context 'when log_messages is set to true' do
it 'includes resourceType/id in error message' do
result = validator.resource_is_valid?(resource2, profile_url, runnable)

expect(result).to be(false)
expect(runnable.messages.first[:message]).to start_with("#{resource2.resourceType}/#{resource2.id}:")
expect(result).to be(false)
expect(runnable.messages.first[:message]).to start_with("#{resource2.resourceType}/#{resource2.id}:")
end
end

context 'when log_messages is set to false' do
it 'does not log messages' do
result = validator.resource_is_valid?(resource2, profile_url, runnable, log_messages: false)

expect(result).to be(false)
expect(runnable.messages).to be_empty
end
end
end

Expand Down
30 changes: 21 additions & 9 deletions spec/inferno/dsl/fhir_validation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,31 @@
.to_return(status: 200, body: invalid_outcome)
end

it 'includes resourceType/id in error message' do
result = validator.resource_is_valid?(resource, profile_url, runnable)
context 'when log_messages is set to true' do
it 'includes resourceType/id in error message' do
result = validator.resource_is_valid?(resource, profile_url, runnable)

expect(result).to be(false)
expect(runnable.messages.first[:message]).to start_with("#{resource.resourceType}/#{resource.id}:")
expect(result).to be(false)
expect(runnable.messages.first[:message]).to start_with("#{resource.resourceType}/#{resource.id}:")
end

it 'includes resourceType in error message if resource.id is nil' do
resource.id = nil
result = validator.resource_is_valid?(resource, profile_url, runnable)

expect(result).to be(false)
expect(runnable.messages.first[:message]).to start_with("#{resource.resourceType}:")
end
end

it 'includes resourceType in error message if resource.id is nil' do
resource.id = nil
result = validator.resource_is_valid?(resource, profile_url, runnable)
context 'when log_messages is set to false' do
it 'does not log messages' do
resource.id = nil
result = validator.resource_is_valid?(resource, profile_url, runnable, log_messages: false)

expect(result).to be(false)
expect(runnable.messages.first[:message]).to start_with("#{resource.resourceType}:")
expect(result).to be(false)
expect(runnable.messages).to be_empty
end
end
end

Expand Down

0 comments on commit f01941c

Please sign in to comment.