inferno_core 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/test_session.rb +3 -3
- data/lib/inferno/public/175.bundle.js +1 -0
- 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 +12 -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
|
@@ -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
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(self.webpackChunkinferno_web_app=self.webpackChunkinferno_web_app||[]).push([[175],{9175:(t,e,n)=>{n.r(e),n.d(e,{getCLS:()=>d,getFCP:()=>m,getFID:()=>v,getLCP:()=>h,getTTFB:()=>S});var i,a,r=function(t){return{name:t,value:arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,delta:0,entries:[],id:"".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),isFinal:!1}},o=function(t,e){try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var n=new PerformanceObserver((function(t){return t.getEntries().map(e)}));return n.observe({type:t,buffered:!0}),n}}catch(t){}},s=!1,u=!1,c=function(t){s=!t.persisted},p=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];u||(addEventListener("pagehide",c),addEventListener("beforeunload",(function(){})),u=!0),addEventListener("visibilitychange",(function(e){var n=e.timeStamp;"hidden"===document.visibilityState&&t({timeStamp:n,isUnloading:s})}),{capture:!0,once:e})},l=function(t,e,n,i){var a;return function(){n&&e.isFinal&&n.disconnect(),e.value>=0&&(i||e.isFinal||"hidden"===document.visibilityState)&&(e.delta=e.value-(a||0),(e.delta||e.isFinal||void 0===a)&&(t(e),a=e.value))}},d=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=r("CLS",0),a=function(t){t.hadRecentInput||(i.value+=t.value,i.entries.push(t),e())},s=o("layout-shift",a);s&&(e=l(t,i,s,n),p((function(t){var n=t.isUnloading;s.takeRecords().map(a),n&&(i.isFinal=!0),e()})))},f=function(){return void 0===i&&(i="hidden"===document.visibilityState?0:1/0,p((function(t){var e=t.timeStamp;return i=e}),!0)),{get timeStamp(){return i}}},m=function(t){var e,n=r("FCP"),i=f(),a=o("paint",(function(t){"first-contentful-paint"===t.name&&t.startTime<i.timeStamp&&(n.value=t.startTime,n.isFinal=!0,n.entries.push(t),e())}));a&&(e=l(t,n,a))},v=function(t){var e=r("FID"),n=f(),i=function(t){t.startTime<n.timeStamp&&(e.value=t.processingStart-t.startTime,e.entries.push(t),e.isFinal=!0,s())},a=o("first-input",i),s=l(t,e,a);a?p((function(){a.takeRecords().map(i),a.disconnect()}),!0):window.perfMetrics&&window.perfMetrics.onFirstInputDelay&&window.perfMetrics.onFirstInputDelay((function(t,i){i.timeStamp<n.timeStamp&&(e.value=t,e.isFinal=!0,e.entries=[{entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+t}],s())}))},g=function(){return a||(a=new Promise((function(t){return["scroll","keydown","pointerdown"].map((function(e){addEventListener(e,t,{once:!0,passive:!0,capture:!0})}))}))),a},h=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=r("LCP"),a=f(),s=function(t){var n=t.startTime;n<a.timeStamp?(i.value=n,i.entries.push(t)):i.isFinal=!0,e()},u=o("largest-contentful-paint",s);if(u){e=l(t,i,u,n);var c=function(){i.isFinal||(u.takeRecords().map(s),i.isFinal=!0,e())};g().then(c),p(c,!0)}},S=function(t){var e,n=r("TTFB");e=function(){try{var e=performance.getEntriesByType("navigation")[0]||function(){var t=performance.timing,e={entryType:"navigation",startTime:0};for(var n in t)"navigationStart"!==n&&"toJSON"!==n&&(e[n]=Math.max(t[n]-t.navigationStart,0));return e}();n.value=n.delta=e.responseStart,n.entries=[e],n.isFinal=!0,t(n)}catch(t){}},"complete"===document.readyState?setTimeout(e,0):addEventListener("pageshow",e)}}}]);
|
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.5.
|
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-11-
|
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
|
@@ -541,6 +545,7 @@ files:
|
|
541
545
|
- lib/inferno/jobs/invoke_validator_session.rb
|
542
546
|
- lib/inferno/jobs/resume_test_run.rb
|
543
547
|
- lib/inferno/public/0e0b993fd6ff351f435ff1c2938daf2d.png
|
548
|
+
- lib/inferno/public/175.bundle.js
|
544
549
|
- lib/inferno/public/217.bundle.js
|
545
550
|
- lib/inferno/public/237.bundle.js
|
546
551
|
- lib/inferno/public/a5cd39450ab0336db73c5e57228b649d.png
|
@@ -588,10 +593,15 @@ files:
|
|
588
593
|
- spec/factories/result.rb
|
589
594
|
- spec/factories/test_run.rb
|
590
595
|
- spec/factories/test_session.rb
|
596
|
+
- spec/features_helper.rb
|
591
597
|
- spec/fixtures/auth_info_constants.rb
|
592
598
|
- spec/fixtures/basic_test_group.rb
|
593
599
|
- spec/fixtures/basic_test_suite.rb
|
594
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
|
595
605
|
- spec/support/factory_bot.rb
|
596
606
|
homepage: https://github.com/inferno-framework/inferno-core
|
597
607
|
licenses:
|