inferno_core 0.4.44 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/inferno/apps/cli/execute/console_outputter.rb +18 -29
- data/lib/inferno/apps/cli/execute/json_outputter.rb +28 -0
- data/lib/inferno/apps/cli/execute/plain_outputter.rb +18 -0
- data/lib/inferno/apps/cli/execute/quiet_outputter.rb +22 -0
- data/lib/inferno/apps/cli/execute/serialize.rb +21 -0
- data/lib/inferno/apps/cli/execute.rb +15 -6
- data/lib/inferno/apps/cli/main.rb +15 -1
- data/lib/inferno/apps/cli/templates/Gemfile.tt +4 -0
- data/lib/inferno/apps/cli/templates/spec/%library_name%/patient_group_spec.rb.tt +1 -12
- data/lib/inferno/apps/cli/templates/spec/spec_helper.rb.tt +1 -1
- data/lib/inferno/dsl/resume_test_route.rb +1 -1
- data/lib/inferno/entities/request.rb +2 -2
- data/lib/inferno/entities/test_session.rb +3 -3
- data/lib/inferno/exceptions.rb +6 -0
- data/lib/inferno/repositories/in_memory_repository.rb +5 -8
- data/lib/inferno/spec_support.rb +8 -0
- data/lib/inferno/version.rb +1 -1
- data/spec/features_helper.rb +12 -0
- data/spec/request_helper.rb +30 -0
- data/spec/runnable_context.rb +43 -0
- data/spec/runnable_helper.rb +11 -0
- data/spec/spec_helper.rb +149 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2266ffdfdf00fea5f565f6b1d5f927ba0c6c64b4d5b5725b737bdb822fe231cd
|
4
|
+
data.tar.gz: bfb17c44e6dabfb9ba46b153e25c1c62aaae6179eaf202505213ab920e4cbcca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a12e012b24105c8f7e3feb22bd12612ccd4c0f4b345b3289d8fc0c946f1229581f476d1a984418e768b6c0baa65145fcd07f2dd27728ca76508328577de4812b
|
7
|
+
data.tar.gz: f0aabd22881fddc9ad3292e15daf717dd5009fc63d46a947a2696c6d684b11ea239cd669d9e89a0efe0b0eb6233a04fe7e3ae4b8839fb024153a555d7b976fe7
|
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'pastel'
|
2
|
-
require_relative '
|
3
|
-
require_relative '../../web/serializers/result'
|
2
|
+
require_relative 'serialize'
|
4
3
|
|
5
4
|
module Inferno
|
6
5
|
module CLI
|
7
6
|
class Execute
|
8
7
|
# @private
|
9
8
|
class ConsoleOutputter
|
10
|
-
COLOR = Pastel.new
|
11
9
|
CHECKMARK = "\u2713".freeze
|
12
10
|
BAR = ('=' * 80).freeze
|
13
11
|
|
12
|
+
include Serialize
|
13
|
+
|
14
14
|
def print_start_message(options)
|
15
15
|
puts ''
|
16
16
|
puts BAR
|
@@ -23,7 +23,6 @@ module Inferno
|
|
23
23
|
|
24
24
|
def print_around_run(_options)
|
25
25
|
puts 'Running tests. This may take a while...'
|
26
|
-
# TODO: spinner/progress bar
|
27
26
|
yield
|
28
27
|
end
|
29
28
|
|
@@ -46,15 +45,18 @@ module Inferno
|
|
46
45
|
|
47
46
|
def print_end_message(options); end
|
48
47
|
|
49
|
-
def print_error(
|
50
|
-
puts
|
51
|
-
verbose_print(options, exception.backtrace&.join('\n'))
|
48
|
+
def print_error(_options, exception)
|
49
|
+
puts color.red "Error: #{exception.full_message}"
|
52
50
|
end
|
53
51
|
|
54
52
|
# private
|
55
53
|
|
56
54
|
def verbose_print(options, *args)
|
57
|
-
print(
|
55
|
+
print(color.dim(*args)) if options[:verbose]
|
56
|
+
end
|
57
|
+
|
58
|
+
def color
|
59
|
+
@color ||= Pastel.new(enabled: $stdout.tty?)
|
58
60
|
end
|
59
61
|
|
60
62
|
def verbose_puts(options, *args)
|
@@ -106,21 +108,21 @@ module Inferno
|
|
106
108
|
def format_result(result) # rubocop:disable Metrics/CyclomaticComplexity
|
107
109
|
case result.result
|
108
110
|
when 'pass'
|
109
|
-
|
111
|
+
color.bold.green(CHECKMARK, ' pass')
|
110
112
|
when 'fail'
|
111
|
-
|
113
|
+
color.bold.red 'X fail'
|
112
114
|
when 'skip'
|
113
|
-
|
115
|
+
color.yellow '* skip'
|
114
116
|
when 'omit'
|
115
|
-
|
117
|
+
color.blue '* omit'
|
116
118
|
when 'error'
|
117
|
-
|
119
|
+
color.magenta 'X error'
|
118
120
|
when 'wait'
|
119
|
-
|
121
|
+
color.bold '. wait'
|
120
122
|
when 'cancel'
|
121
|
-
|
123
|
+
color.red 'X cancel'
|
122
124
|
when 'running'
|
123
|
-
|
125
|
+
color.bold '- running'
|
124
126
|
else
|
125
127
|
raise StandardError.new, "Unrecognized result #{result.result}"
|
126
128
|
end
|
@@ -133,19 +135,6 @@ module Inferno
|
|
133
135
|
verbose_puts(options, serialize(results))
|
134
136
|
verbose_puts(options, BAR)
|
135
137
|
end
|
136
|
-
|
137
|
-
def serialize(entity)
|
138
|
-
case entity.class.to_s
|
139
|
-
when 'Array'
|
140
|
-
JSON.pretty_generate(entity.map { |item| JSON.parse serialize(item) })
|
141
|
-
when lambda { |x|
|
142
|
-
defined?(x.constantize) && defined?("Inferno::Web::Serializers::#{x.split('::').last}".constantize)
|
143
|
-
}
|
144
|
-
"Inferno::Web::Serializers::#{entity.class.to_s.split('::').last}".constantize.render(entity)
|
145
|
-
else
|
146
|
-
raise StandardError, "CLI does not know how to serialize #{entity.class}"
|
147
|
-
end
|
148
|
-
end
|
149
138
|
end
|
150
139
|
end
|
151
140
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative 'serialize'
|
2
|
+
|
3
|
+
module Inferno
|
4
|
+
module CLI
|
5
|
+
class Execute
|
6
|
+
# @private
|
7
|
+
class JSONOutputter
|
8
|
+
include Serialize
|
9
|
+
|
10
|
+
def print_start_message(_options); end
|
11
|
+
|
12
|
+
def print_around_run(_options, &)
|
13
|
+
yield
|
14
|
+
end
|
15
|
+
|
16
|
+
def print_results(_options, results)
|
17
|
+
puts serialize(results)
|
18
|
+
end
|
19
|
+
|
20
|
+
def print_end_message(_options); end
|
21
|
+
|
22
|
+
def print_error(_options, exception)
|
23
|
+
puts exception.to_json
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'console_outputter'
|
2
|
+
|
3
|
+
module Inferno
|
4
|
+
module CLI
|
5
|
+
class Execute
|
6
|
+
# @private
|
7
|
+
class PlainOutputter < ConsoleOutputter
|
8
|
+
def print_error(_options, exception)
|
9
|
+
puts "Error: #{exception.full_message(highlight: false)}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def color
|
13
|
+
@color ||= Pastel.new(enabled: false)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Inferno
|
2
|
+
module CLI
|
3
|
+
class Execute
|
4
|
+
# @private
|
5
|
+
class QuietOutputter
|
6
|
+
def print_start_message(_options); end
|
7
|
+
|
8
|
+
def print_around_run(_options, &)
|
9
|
+
yield
|
10
|
+
end
|
11
|
+
|
12
|
+
def print_results(_options, _results); end
|
13
|
+
|
14
|
+
def print_end_message(_options); end
|
15
|
+
|
16
|
+
def print_error(options, exception)
|
17
|
+
puts "Error: #{exception.full_message}" if options[:verbose]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require_relative '../../web/serializers/test_run'
|
3
|
+
require_relative '../../web/serializers/result'
|
4
|
+
|
5
|
+
module Inferno
|
6
|
+
module CLI
|
7
|
+
class Execute
|
8
|
+
# @private
|
9
|
+
module Serialize
|
10
|
+
def serialize(entity)
|
11
|
+
case entity.class.to_s
|
12
|
+
when 'Array'
|
13
|
+
JSON.pretty_generate(entity.map { |item| JSON.parse serialize(item) })
|
14
|
+
else
|
15
|
+
Inferno::Web::Serializers.const_get(entity.class.to_s.demodulize).render(entity)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
require 'pastel'
|
2
1
|
require 'active_support'
|
3
2
|
require_relative '../../utils/verify_runnable'
|
4
3
|
require_relative '../../utils/persist_inputs'
|
5
|
-
|
6
|
-
|
4
|
+
|
5
|
+
Dir[File.join(__dir__, 'execute', '*_outputter.rb')].each { |outputter| require outputter }
|
7
6
|
|
8
7
|
module Inferno
|
9
8
|
module CLI
|
@@ -11,6 +10,13 @@ module Inferno
|
|
11
10
|
include ::Inferno::Utils::VerifyRunnable
|
12
11
|
include ::Inferno::Utils::PersistInputs
|
13
12
|
|
13
|
+
OUTPUTTERS = {
|
14
|
+
'console' => Inferno::CLI::Execute::ConsoleOutputter,
|
15
|
+
'plain' => Inferno::CLI::Execute::PlainOutputter,
|
16
|
+
'json' => Inferno::CLI::Execute::JSONOutputter,
|
17
|
+
'quiet' => Inferno::CLI::Execute::QuietOutputter
|
18
|
+
}.freeze
|
19
|
+
|
14
20
|
attr_accessor :options
|
15
21
|
|
16
22
|
def self.suppress_output
|
@@ -88,8 +94,12 @@ module Inferno
|
|
88
94
|
end
|
89
95
|
|
90
96
|
def outputter
|
91
|
-
|
92
|
-
|
97
|
+
unless OUTPUTTERS.key? options[:outputter]
|
98
|
+
raise StandardError,
|
99
|
+
"Unrecognized outputter #{options[:outputter]}"
|
100
|
+
end
|
101
|
+
|
102
|
+
@outputter ||= OUTPUTTERS[options[:outputter]].new
|
93
103
|
end
|
94
104
|
|
95
105
|
def all_selected_groups_and_tests
|
@@ -164,7 +174,6 @@ module Inferno
|
|
164
174
|
end
|
165
175
|
|
166
176
|
def dispatch_job(test_run)
|
167
|
-
# TODO: move suppression to outputter? better suppression?
|
168
177
|
if options[:verbose]
|
169
178
|
Jobs.perform(Jobs::ExecuteTestRun, test_run.id, force_synchronous: true)
|
170
179
|
else
|
@@ -74,6 +74,10 @@ module Inferno
|
|
74
74
|
|
75
75
|
You can view suite ids with: `bundle exec inferno suites`
|
76
76
|
|
77
|
+
You can select an output format with the `--outputter` option. Current outputters
|
78
|
+
are console (default), plain, quiet, and json. JSON-formatted output will copy
|
79
|
+
Inferno's REST API: https://inferno-framework.github.io/inferno-core/api-docs/#/Result.
|
80
|
+
|
77
81
|
Examples:
|
78
82
|
|
79
83
|
(These examples only work from within the inferno_core directory).
|
@@ -88,6 +92,12 @@ module Inferno
|
|
88
92
|
patient_id:1234321 \
|
89
93
|
--tests 1.01 1.02`
|
90
94
|
=> Run specific tests from suite
|
95
|
+
|
96
|
+
`bundle exec inferno execute --suite dev_validator \
|
97
|
+
--inputs "url:https://hapi.fhir.org/baseR4" \
|
98
|
+
patient_id:1234321 \
|
99
|
+
--outputter json`
|
100
|
+
=> Outputs test results in JSON
|
91
101
|
END_OF_HELP
|
92
102
|
desc 'execute', 'Run Inferno tests in command line'
|
93
103
|
long_desc EXECUTE_HELP, wrap: false
|
@@ -97,7 +107,7 @@ module Inferno
|
|
97
107
|
desc: 'Test suite id to run or to select groups and tests from',
|
98
108
|
banner: 'id'
|
99
109
|
option :suite_options,
|
100
|
-
aliases: ['-u'],
|
110
|
+
aliases: ['-u'],
|
101
111
|
type: :hash,
|
102
112
|
desc: 'Suite options'
|
103
113
|
option :groups,
|
@@ -116,6 +126,10 @@ module Inferno
|
|
116
126
|
aliases: ['-i'],
|
117
127
|
type: :hash,
|
118
128
|
desc: 'Inputs (i.e: --inputs=foo:bar goo:baz)'
|
129
|
+
option :outputter,
|
130
|
+
aliases: ['-o'],
|
131
|
+
default: 'console',
|
132
|
+
desc: 'Select an outputter format: console | plain | json | quiet'
|
119
133
|
option :verbose,
|
120
134
|
aliases: ['-v'],
|
121
135
|
type: :boolean,
|
@@ -1,8 +1,6 @@
|
|
1
1
|
RSpec.describe <%= module_name %>::PatientGroup do
|
2
|
-
let(:
|
2
|
+
let(:suite_id) { '<%= test_suite_id %>' }
|
3
3
|
let(:group) { suite.groups[1] }
|
4
|
-
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
|
5
|
-
let(:test_session) { repo_create(:test_session, test_suite_id: '<%= test_suite_id %>') }
|
6
4
|
let(:url) { 'http://example.com/fhir' }
|
7
5
|
let(:success_outcome) do
|
8
6
|
{
|
@@ -25,15 +23,6 @@ RSpec.describe <%= module_name %>::PatientGroup do
|
|
25
23
|
}
|
26
24
|
end
|
27
25
|
|
28
|
-
def run(runnable, inputs = {})
|
29
|
-
test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash)
|
30
|
-
test_run = Inferno::Repositories::TestRuns.new.create(test_run_params)
|
31
|
-
inputs.each do |name, value|
|
32
|
-
session_data_repo.save(test_session_id: test_session.id, name: name, value: value, type: 'text')
|
33
|
-
end
|
34
|
-
Inferno::TestRunner.new(test_session: test_session, test_run: test_run).run(runnable)
|
35
|
-
end
|
36
|
-
|
37
26
|
describe 'read test' do
|
38
27
|
let(:test) { group.tests.first }
|
39
28
|
let(:patient_id) { 'abc123' }
|
@@ -127,7 +127,7 @@ Inferno::Utils::Migration.new.run
|
|
127
127
|
require 'inferno'
|
128
128
|
Inferno::Application.finalize!
|
129
129
|
|
130
|
-
|
130
|
+
Inferno::SpecSupport.require_helpers
|
131
131
|
|
132
132
|
FactoryBot.definition_file_paths = [
|
133
133
|
Inferno::SpecSupport::FACTORY_PATH
|
@@ -181,7 +181,7 @@ module Inferno
|
|
181
181
|
.map { |header_name, value| Header.new(name: header_name.downcase, value:, type: 'response') }
|
182
182
|
|
183
183
|
new(
|
184
|
-
verb: response.env.method,
|
184
|
+
verb: response.env.method.downcase,
|
185
185
|
url: response.env.url.to_s,
|
186
186
|
direction:,
|
187
187
|
name:,
|
@@ -210,7 +210,7 @@ module Inferno
|
|
210
210
|
end
|
211
211
|
|
212
212
|
new(
|
213
|
-
verb: request[:method],
|
213
|
+
verb: request[:method].downcase,
|
214
214
|
url: request[:url],
|
215
215
|
direction:,
|
216
216
|
name:,
|
@@ -12,13 +12,13 @@ module Inferno
|
|
12
12
|
# @return [String] id of the `TestSuite` being run in this session
|
13
13
|
# @!attribute test_suite
|
14
14
|
# @return [Inferno::Entities::TestSuite] the `TestSuite` being run in this
|
15
|
-
#
|
15
|
+
# session
|
16
16
|
# @!attribute test_runs
|
17
17
|
# @return [Array<Inferno::Entities::TestRun>] the `TestRuns` associated
|
18
|
-
#
|
18
|
+
# with this session
|
19
19
|
# @!attribute results
|
20
20
|
# @return [Array<Inferno::Entities::TestResult>] the `TestResults`
|
21
|
-
#
|
21
|
+
# associated with this session
|
22
22
|
# @!attribute suite_options
|
23
23
|
# @return [Hash] the suite options associated with this session
|
24
24
|
class TestSession < Entity
|
data/lib/inferno/exceptions.rb
CHANGED
@@ -119,5 +119,11 @@ module Inferno
|
|
119
119
|
super("ID '#{id}' exceeds the maximum id length of 255 characters")
|
120
120
|
end
|
121
121
|
end
|
122
|
+
|
123
|
+
class DuplicateEntityIdException < StandardError
|
124
|
+
def initialize(id)
|
125
|
+
super("ID '#{id}' already exists. Ensure the uniqueness of the IDs.")
|
126
|
+
end
|
127
|
+
end
|
122
128
|
end
|
123
129
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'forwardable'
|
2
|
+
require_relative '../exceptions'
|
2
3
|
|
3
4
|
module Inferno
|
4
5
|
module Repositories
|
@@ -8,7 +9,10 @@ module Inferno
|
|
8
9
|
def_delegators 'self.class', :all, :all_by_id
|
9
10
|
|
10
11
|
def insert(entity)
|
12
|
+
raise Exceptions::DuplicateEntityIdException, entity.id if exists?(entity.id)
|
13
|
+
|
11
14
|
all << entity
|
15
|
+
all_by_id[entity.id.to_s] = entity
|
12
16
|
entity
|
13
17
|
end
|
14
18
|
|
@@ -17,7 +21,7 @@ module Inferno
|
|
17
21
|
end
|
18
22
|
|
19
23
|
def exists?(id)
|
20
|
-
all_by_id.
|
24
|
+
all_by_id.key?(id.to_s)
|
21
25
|
end
|
22
26
|
|
23
27
|
class << self
|
@@ -28,13 +32,6 @@ module Inferno
|
|
28
32
|
# @private
|
29
33
|
def all_by_id
|
30
34
|
@all_by_id ||= {}
|
31
|
-
@all_by_id.length == all.length ? @all_by_id : index_by_id
|
32
|
-
end
|
33
|
-
|
34
|
-
def index_by_id
|
35
|
-
@all_by_id = {}
|
36
|
-
all.each { |klass| @all_by_id[klass.id] = klass }
|
37
|
-
@all_by_id
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
data/lib/inferno/spec_support.rb
CHANGED
@@ -5,5 +5,13 @@ module Inferno
|
|
5
5
|
module SpecSupport
|
6
6
|
FACTORY_BOT_SUPPORT_PATH = File.expand_path('../../spec/support/factory_bot', __dir__).freeze
|
7
7
|
FACTORY_PATH = File.expand_path('../../spec/factories', __dir__).freeze
|
8
|
+
REQUEST_HELPER_PATH = File.expand_path('../../spec/request_helper', __dir__).freeze
|
9
|
+
RUNNABLE_HELPER_PATH = File.expand_path('../../spec/runnable_helper', __dir__).freeze
|
10
|
+
|
11
|
+
def self.require_helpers
|
12
|
+
require FACTORY_BOT_SUPPORT_PATH
|
13
|
+
require RUNNABLE_HELPER_PATH
|
14
|
+
require REQUEST_HELPER_PATH
|
15
|
+
end
|
8
16
|
end
|
9
17
|
end
|
data/lib/inferno/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Require this file for feature tests
|
2
|
+
require_relative 'spec_helper'
|
3
|
+
|
4
|
+
require 'capybara'
|
5
|
+
require 'capybara/rspec'
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.include RSpec::FeatureExampleGroup
|
9
|
+
|
10
|
+
config.include Capybara::DSL, feature: true
|
11
|
+
config.include Capybara::RSpecMatchers, feature: true
|
12
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rack/test'
|
3
|
+
require_relative '../lib/inferno/apps/web/application'
|
4
|
+
require_relative '../lib/inferno/utils/middleware/request_logger'
|
5
|
+
|
6
|
+
module RequestHelpers
|
7
|
+
def app
|
8
|
+
Rack::Builder.new do
|
9
|
+
use Inferno::Utils::Middleware::RequestLogger
|
10
|
+
run Inferno::Web.app
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def post_json(path, data)
|
15
|
+
post path, data.to_json, 'CONTENT_TYPE' => 'application/json'
|
16
|
+
end
|
17
|
+
|
18
|
+
def parsed_body
|
19
|
+
JSON.parse(last_response.body)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.define_derived_metadata(file_path: %r{/spec/requests/}) do |metadata|
|
25
|
+
metadata[:request] = true
|
26
|
+
end
|
27
|
+
|
28
|
+
config.include Rack::Test::Methods, request: true
|
29
|
+
config.include RequestHelpers, request: true
|
30
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
RSpec.shared_context('when testing a runnable') do
|
2
|
+
let(:suite) { Inferno::Repositories::TestSuites.new.find(suite_id) }
|
3
|
+
let(:session_data_repo) { Inferno::Repositories::SessionData.new }
|
4
|
+
let(:validation_url) { "#{ENV.fetch('FHIR_RESOURCE_VALIDATOR_URL')}/validate" }
|
5
|
+
let(:test_session) { repo_create(:test_session, test_suite_id: suite_id) }
|
6
|
+
|
7
|
+
before do
|
8
|
+
allow(described_class).to receive(:suite).and_return(suite) if described_class.parent.nil?
|
9
|
+
rescue NameError
|
10
|
+
raise StandardError, "No suite id defined. Add `let(:suite_id) { 'your_suite_id' }` to the spec"
|
11
|
+
end
|
12
|
+
|
13
|
+
def run(runnable, inputs = {})
|
14
|
+
test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash)
|
15
|
+
test_run = Inferno::Repositories::TestRuns.new.create(test_run_params)
|
16
|
+
inputs.each do |name, value|
|
17
|
+
session_data_repo.save(
|
18
|
+
test_session_id: test_session.id,
|
19
|
+
name:,
|
20
|
+
value:,
|
21
|
+
type: runnable.config.input_type(name)
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
Inferno::TestRunner.new(test_session:, test_run:).run(runnable)
|
26
|
+
end
|
27
|
+
|
28
|
+
# depth-first search looking for a runnable with a runtime id
|
29
|
+
# (prefixed with the ancestor suite / group ids) that ends
|
30
|
+
# with the provided suffix. It can be the test's id if unique, or
|
31
|
+
# can include some ancestor context if needed to identify the
|
32
|
+
# correct test. The first matching test found will be returned.
|
33
|
+
def find_test(runnable, id_suffix)
|
34
|
+
return runnable if runnable.id.ends_with?(id_suffix)
|
35
|
+
|
36
|
+
runnable.children.each do |entity|
|
37
|
+
found = find_test(entity, id_suffix)
|
38
|
+
return found unless found.nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative 'runnable_context'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.define_derived_metadata do |metadata|
|
5
|
+
if metadata[:described_class].present? && metadata[:described_class].is_a?(Inferno::DSL::Runnable)
|
6
|
+
metadata[:runnable] = true
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
config.include_context 'when testing a runnable', runnable: true
|
11
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
# Hide deprecation warnings
|
2
|
+
$VERBOSE = nil
|
3
|
+
|
4
|
+
ENV['APP_ENV'] ||= 'test'
|
5
|
+
|
6
|
+
require 'pry'
|
7
|
+
require 'database_cleaner/sequel'
|
8
|
+
|
9
|
+
require 'simplecov'
|
10
|
+
SimpleCov.start do
|
11
|
+
enable_coverage :branch
|
12
|
+
add_filter '/spec/'
|
13
|
+
add_filter '/lib/inferno/db/migrations'
|
14
|
+
add_filter '/lib/inferno/db/schema.rb'
|
15
|
+
add_filter '/lib/inferno/apps/cli'
|
16
|
+
add_filter '/lib/inferno/ext/rack.rb'
|
17
|
+
end
|
18
|
+
|
19
|
+
if ENV['GITHUB_ACTIONS']
|
20
|
+
require 'simplecov-cobertura'
|
21
|
+
SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'webmock/rspec'
|
25
|
+
WebMock.disable_net_connect!
|
26
|
+
|
27
|
+
require 'factory_bot'
|
28
|
+
|
29
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
30
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
31
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
32
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
33
|
+
# files.
|
34
|
+
#
|
35
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
36
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
37
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
38
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
39
|
+
# a separate helper file that requires the additional dependencies and performs
|
40
|
+
# the additional setup, and require it from the spec files that actually need
|
41
|
+
# it.
|
42
|
+
#
|
43
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
44
|
+
# users commonly want.
|
45
|
+
#
|
46
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
47
|
+
RSpec.configure do |config|
|
48
|
+
# rspec-expectations config goes here. You can use an alternate
|
49
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
50
|
+
# assertions if you prefer.
|
51
|
+
config.expect_with :rspec do |expectations|
|
52
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
53
|
+
# and `failure_message` of custom matchers include text for helper methods
|
54
|
+
# defined using `chain`, e.g.:
|
55
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
56
|
+
# # => "be bigger than 2 and smaller than 4"
|
57
|
+
# ...rather than:
|
58
|
+
# # => "be bigger than 2"
|
59
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
60
|
+
end
|
61
|
+
|
62
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
63
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
64
|
+
config.mock_with :rspec do |mocks|
|
65
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
66
|
+
# a real object. This is generally recommended, and will default to
|
67
|
+
# `true` in RSpec 4.
|
68
|
+
mocks.verify_partial_doubles = true
|
69
|
+
end
|
70
|
+
|
71
|
+
# Allows RSpec to persist some state between runs in order to support
|
72
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
73
|
+
# you configure your source control system to ignore this file.
|
74
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
75
|
+
|
76
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
77
|
+
# recommended. For more details, see:
|
78
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
79
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
80
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
81
|
+
config.disable_monkey_patching!
|
82
|
+
|
83
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
84
|
+
# file, and it's useful to allow more verbose output when running an
|
85
|
+
# individual spec file.
|
86
|
+
if config.files_to_run.one?
|
87
|
+
# Use the documentation formatter for detailed output,
|
88
|
+
# unless a formatter has already been configured
|
89
|
+
# (e.g. via a command-line flag).
|
90
|
+
config.default_formatter = 'doc'
|
91
|
+
end
|
92
|
+
|
93
|
+
# Run specs in random order to surface order dependencies. If you find an
|
94
|
+
# order dependency and want to debug it, you can fix the order by providing
|
95
|
+
# the seed, which is printed after each run.
|
96
|
+
# --seed 1234
|
97
|
+
config.order = :random
|
98
|
+
|
99
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
100
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
101
|
+
# test failures related to randomization by passing the same `--seed` value
|
102
|
+
# as the one that triggered the failure.
|
103
|
+
Kernel.srand config.seed
|
104
|
+
|
105
|
+
# These two settings work together to allow you to limit a spec run
|
106
|
+
# to individual examples or groups you care about by tagging them with
|
107
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
108
|
+
# get run.
|
109
|
+
config.filter_run :focus
|
110
|
+
config.run_all_when_everything_filtered = true
|
111
|
+
|
112
|
+
# This setting enables warnings. It's recommended, but in many cases may
|
113
|
+
# be too noisy due to issues in dependencies.
|
114
|
+
# config.warnings = false
|
115
|
+
|
116
|
+
# Print the 10 slowest examples and example groups at the
|
117
|
+
# end of the spec run, to help surface which specs are running
|
118
|
+
# particularly slow.
|
119
|
+
# config.profile_examples = 10
|
120
|
+
|
121
|
+
config.before(:suite) do
|
122
|
+
DatabaseCleaner.strategy = :transaction
|
123
|
+
DatabaseCleaner.clean_with(:truncation)
|
124
|
+
end
|
125
|
+
|
126
|
+
config.around do |example|
|
127
|
+
DatabaseCleaner.cleaning { example.run }
|
128
|
+
end
|
129
|
+
|
130
|
+
config.include FactoryBot::Syntax::Methods
|
131
|
+
|
132
|
+
config.before(:suite) do
|
133
|
+
FactoryBot.find_definitions
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
require_relative '../lib/inferno/config/application'
|
138
|
+
require_relative '../lib/inferno/utils/migration'
|
139
|
+
Inferno::Utils::Migration.new.run
|
140
|
+
Inferno::Application.finalize!
|
141
|
+
|
142
|
+
Inferno::SpecSupport.require_helpers
|
143
|
+
|
144
|
+
RSpec::Matchers.define_negated_matcher :exclude, :include
|
145
|
+
require 'fhir_client'
|
146
|
+
FHIR.logger = Inferno::Application['logger']
|
147
|
+
|
148
|
+
DatabaseCleaner[:sequel].strategy = :truncation
|
149
|
+
DatabaseCleaner[:sequel].db = Inferno::Application['db.connection']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inferno_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen MacVicar
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-11-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -392,6 +392,10 @@ files:
|
|
392
392
|
- lib/inferno/apps/cli/console.rb
|
393
393
|
- lib/inferno/apps/cli/execute.rb
|
394
394
|
- lib/inferno/apps/cli/execute/console_outputter.rb
|
395
|
+
- lib/inferno/apps/cli/execute/json_outputter.rb
|
396
|
+
- lib/inferno/apps/cli/execute/plain_outputter.rb
|
397
|
+
- lib/inferno/apps/cli/execute/quiet_outputter.rb
|
398
|
+
- lib/inferno/apps/cli/execute/serialize.rb
|
395
399
|
- lib/inferno/apps/cli/main.rb
|
396
400
|
- lib/inferno/apps/cli/migration.rb
|
397
401
|
- lib/inferno/apps/cli/new.rb
|
@@ -589,10 +593,15 @@ files:
|
|
589
593
|
- spec/factories/result.rb
|
590
594
|
- spec/factories/test_run.rb
|
591
595
|
- spec/factories/test_session.rb
|
596
|
+
- spec/features_helper.rb
|
592
597
|
- spec/fixtures/auth_info_constants.rb
|
593
598
|
- spec/fixtures/basic_test_group.rb
|
594
599
|
- spec/fixtures/basic_test_suite.rb
|
595
600
|
- spec/fixtures/run_as_group_test_group.rb
|
601
|
+
- spec/request_helper.rb
|
602
|
+
- spec/runnable_context.rb
|
603
|
+
- spec/runnable_helper.rb
|
604
|
+
- spec/spec_helper.rb
|
596
605
|
- spec/support/factory_bot.rb
|
597
606
|
homepage: https://github.com/inferno-framework/inferno-core
|
598
607
|
licenses:
|