diff --git a/.rubocop.yml b/.rubocop.yml index 571621e64..94e7f2252 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -81,9 +81,11 @@ RSpec/DescribeClass: RSpec/ExampleLength: Enabled: false -RSpec/FilePath: +RSpec/SpecFilePathFormat: CustomTransform: OAuthCredentials: oauth_credentials + Exclude: + - 'spec/inferno/dsl/test_creation_spec.rb' RSpec/MultipleExpectations: Enabled: false diff --git a/Gemfile b/Gemfile index 5676ffc62..6f71bc29c 100644 --- a/Gemfile +++ b/Gemfile @@ -15,8 +15,6 @@ gemspec group :development, :test do gem 'debug' - gem 'pry' - gem 'pry-byebug' gem 'rubocop', '~> 1.9' gem 'rubocop-rake', require: false gem 'rubocop-rspec', require: false @@ -29,11 +27,12 @@ group :development do end group :test do + gem 'codecov', '0.5.2' gem 'database_cleaner-sequel' + gem 'factory_bot', '~> 6.1' gem 'rack-test' - gem 'rspec' - gem 'simplecov', require: false + gem 'rspec', '~> 3.10' + gem 'simplecov', '0.21.2', require: false gem 'simplecov-cobertura' - gem 'webmock' - gem 'factory_bot' -end \ No newline at end of file + gem 'webmock', '~> 3.11' +end diff --git a/Gemfile.lock b/Gemfile.lock index 7a94d2b1e..3cb12e30c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,16 +32,16 @@ PATH GEM remote: https://rubygems.org/ specs: - activesupport (6.1.7.6) + activesupport (6.1.7.9) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) ast (2.4.2) - backports (3.23.0) + backports (3.25.0) base62-rb (0.3.1) base64 (0.2.0) bcp47 (0.3.3) @@ -52,20 +52,21 @@ GEM codecov (0.5.2) simplecov (>= 0.15, < 0.22) coderay (1.1.3) - concurrent-ruby (1.2.2) + concurrent-ruby (1.3.4) connection_pool (2.4.1) - crack (0.4.5) + crack (1.0.0) + bigdecimal rexml database_cleaner-core (2.0.1) - database_cleaner-sequel (2.0.0) + database_cleaner-sequel (2.0.2) database_cleaner-core (~> 2.0.0) sequel date_time_precision (0.8.1) - debug (1.7.1) - irb (>= 1.5.0) - reline (>= 0.3.1) - diff-lcs (1.5.0) - docile (1.4.0) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.5.1) + docile (1.4.1) domain_name (0.6.20240107) dotenv (2.8.1) dry-auto_inject (1.0.1) @@ -87,7 +88,7 @@ GEM dry-inflector (~> 1.0, < 2) dry-transformer (1.0.1) zeitwerk (~> 2.6) - factory_bot (6.2.0) + factory_bot (6.5.0) activesupport (>= 5.0.0) faraday (1.10.4) faraday-em_http (~> 1.0) @@ -130,7 +131,7 @@ GEM date_time_precision (>= 0.8) mime-types (>= 3.0) nokogiri (>= 1.11.4) - fhir_models (4.3.0) + fhir_models (5.0.0) bcp47 (>= 0.3) date_time_precision (>= 0.8) mime-types (>= 3.0) @@ -155,24 +156,29 @@ GEM dry-core (~> 1.0, < 2) dry-transformer (~> 1.0, < 2) hansi (0.2.1) - hashdiff (1.0.1) + hashdiff (1.1.1) http-accept (1.7.0) http-cookie (1.0.7) domain_name (~> 0.5) - i18n (1.12.0) + i18n (1.14.6) concurrent-ruby (~> 1.0) - io-console (0.6.0) - irb (1.6.2) - reline (>= 0.3.0) - jwt (2.9.1) + io-console (0.7.2) + irb (1.14.1) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + json (2.7.2) + jwt (2.9.3) base64 kramdown (2.4.0) rexml - method_source (1.0.0) - mime-types (3.5.2) + language_server-protocol (3.17.0.3) + logger (1.6.1) + method_source (1.1.0) + mime-types (3.6.0) + logger mime-types-data (~> 3.2015) - mime-types-data (3.2024.0903) - minitest (5.18.0) + mime-types-data (3.2024.1001) + minitest (5.25.1) multi_json (1.15.0) multi_xml (0.7.1) bigdecimal (~> 3.1) @@ -197,70 +203,76 @@ GEM multi_xml (~> 0.5) rack (>= 1.2, < 4) oj (3.11.0) - parallel (1.21.0) - parser (3.1.0.0) + ostruct (0.6.0) + parallel (1.26.3) + parser (3.3.5.0) ast (~> 2.4.1) + racc pastel (0.8.0) tty-color (~> 0.5) - pry (0.13.1) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.9.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.13.0) - public_suffix (4.0.7) + pry (>= 0.13, < 0.15) + psych (5.1.2) + stringio + public_suffix (6.0.1) puma (5.6.9) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.9) - rack-test (1.1.0) - rack (>= 1.0, < 3) + rack (2.2.10) + rack-test (2.1.0) + rack (>= 1.3) rainbow (3.1.1) rake (13.2.1) + rdoc (6.7.0) + psych (>= 4.0.0) redis-client (0.22.2) connection_pool - regexp_parser (2.2.0) - reline (0.3.2) + regexp_parser (2.9.2) + reline (0.5.10) io-console (~> 0.5) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.2.8) - strscan (>= 3.0.9) + rexml (3.3.8) rouge (4.4.0) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.1) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-support (3.11.0) - rubocop (1.25.1) + rspec-support (~> 3.13.0) + rspec-support (3.13.1) + rubocop (1.67.0) + json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.15.1, < 2.0) + regexp_parser (>= 2.4, < 3.0) + rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.15.1) - parser (>= 3.0.1.1) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.3) + parser (>= 3.3.1.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (2.8.0) - rubocop (~> 1.19) - rubocop-sequel (0.3.3) + rubocop-rspec (3.1.0) + rubocop (~> 1.61) + rubocop-sequel (0.3.4) rubocop (~> 1.0) - ruby-progressbar (1.11.0) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) sequel (5.42.0) sidekiq (7.2.4) @@ -275,17 +287,17 @@ GEM simplecov-cobertura (2.1.0) rexml simplecov (~> 0.19) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.3) + simplecov-html (0.13.1) + simplecov_json_formatter (0.1.4) sqlite3 (1.7.3-arm64-darwin) sqlite3 (1.7.3-x86_64-darwin) sqlite3 (1.7.3-x86_64-linux) + stringio (3.1.1) strings (0.2.1) strings-ansi (~> 0.2) unicode-display_width (>= 1.5, < 3.0) unicode_utils (~> 1.4) strings-ansi (0.2.0) - strscan (3.1.0) thor (1.2.2) tilt (2.4.0) tty-color (0.6.0) @@ -299,18 +311,19 @@ GEM tty-screen (0.8.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode-display_width (2.1.0) + unicode-display_width (2.6.0) unicode_utils (1.4.0) - webmock (3.14.0) + webmock (3.24.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - yard (0.9.36) - yard-junk (0.0.9) + yard (0.9.37) + yard-junk (0.0.10) backports (>= 3.18) + ostruct rainbow yard - zeitwerk (2.6.7) + zeitwerk (2.6.18) PLATFORMS arm64-darwin-21 @@ -323,19 +336,17 @@ DEPENDENCIES codecov (= 0.5.2) database_cleaner-sequel debug - factory_bot + factory_bot (~> 6.1) inferno_core! - pry - pry-byebug rack-test - rspec + rspec (~> 3.10) rubocop (~> 1.9) rubocop-rake rubocop-rspec rubocop-sequel - simplecov + simplecov (= 0.21.2) simplecov-cobertura - webmock + webmock (~> 3.11) yard yard-junk @@ -343,4 +354,4 @@ RUBY VERSION ruby 3.1.2p20 BUNDLED WITH - 2.3.23 + 2.4.22 diff --git a/inferno_core.gemspec b/inferno_core.gemspec index e3c08b516..d0ae92b94 100644 --- a/inferno_core.gemspec +++ b/inferno_core.gemspec @@ -11,44 +11,32 @@ Gem::Specification.new do |spec| spec.description = 'Inferno Core is an open source tool for testing data exchanges enabled by the FHIR standand' spec.homepage = 'https://github.com/inferno-framework/inferno-core' spec.license = 'Apache-2.0' - spec.add_runtime_dependency 'activesupport', '~> 6.1.7.5' - spec.add_runtime_dependency 'base62-rb', '0.3.1' - spec.add_runtime_dependency 'blueprinter', '0.25.2' - spec.add_runtime_dependency 'dotenv', '~> 2.7' - spec.add_runtime_dependency 'dry-configurable', '1.0.0' - spec.add_runtime_dependency 'dry-container', '0.10.0' - spec.add_runtime_dependency 'dry-core', '1.0.0' - spec.add_runtime_dependency 'dry-inflector', '1.0.0' - spec.add_runtime_dependency 'dry-system', '1.0.0' - spec.add_runtime_dependency 'faraday', '~> 1.2' - spec.add_runtime_dependency 'faraday_middleware', '~> 1.2' - spec.add_runtime_dependency 'fhir_client', '>= 5.0.3' - spec.add_runtime_dependency 'fhir_models', '>= 4.2.2' - spec.add_runtime_dependency 'hanami-controller', '2.0.0' - spec.add_runtime_dependency 'hanami-router', '2.0.0' - spec.add_runtime_dependency 'oj', '3.11.0' - spec.add_runtime_dependency 'pastel', '~> 0.8.0' - spec.add_runtime_dependency 'pry' - spec.add_runtime_dependency 'pry-byebug' - spec.add_runtime_dependency 'puma', '~> 5.6.7' - spec.add_runtime_dependency 'rake', '~> 13.0' - spec.add_runtime_dependency 'sequel', '~> 5.42.0' - spec.add_runtime_dependency 'sidekiq', '~> 7.2.4' - spec.add_runtime_dependency 'sqlite3', '~> 1.4' - spec.add_runtime_dependency 'thor', '~> 1.2.1' - spec.add_runtime_dependency 'tty-markdown', '~> 0.7.1' - spec.add_development_dependency 'codecov', '0.5.2' - spec.add_development_dependency 'database_cleaner-sequel', '~> 1.8' - spec.add_development_dependency 'factory_bot', '~> 6.1' - spec.add_development_dependency 'rack-test', '~> 1.1' - spec.add_development_dependency 'rspec', '~> 3.10' - spec.add_development_dependency 'rubocop', '~> 1.9' - spec.add_development_dependency 'rubocop-rake', '0.5.1' - spec.add_development_dependency 'rubocop-rspec', '~> 2.1' - spec.add_development_dependency 'rubocop-sequel', '0.1.0' - spec.add_development_dependency 'simplecov', '0.21.2' - spec.add_development_dependency 'webmock', '~> 3.11' - spec.add_development_dependency 'yard', '0.9.26' + spec.add_dependency 'activesupport', '~> 6.1.7.5' + spec.add_dependency 'base62-rb', '0.3.1' + spec.add_dependency 'blueprinter', '0.25.2' + spec.add_dependency 'dotenv', '~> 2.7' + spec.add_dependency 'dry-configurable', '1.0.0' + spec.add_dependency 'dry-container', '0.10.0' + spec.add_dependency 'dry-core', '1.0.0' + spec.add_dependency 'dry-inflector', '1.0.0' + spec.add_dependency 'dry-system', '1.0.0' + spec.add_dependency 'faraday', '~> 1.2' + spec.add_dependency 'faraday_middleware', '~> 1.2' + spec.add_dependency 'fhir_client', '>= 5.0.3' + spec.add_dependency 'fhir_models', '>= 4.2.2' + spec.add_dependency 'hanami-controller', '2.0.0' + spec.add_dependency 'hanami-router', '2.0.0' + spec.add_dependency 'oj', '3.11.0' + spec.add_dependency 'pastel', '~> 0.8.0' + spec.add_dependency 'pry' + spec.add_dependency 'pry-byebug' + spec.add_dependency 'puma', '~> 5.6.7' + spec.add_dependency 'rake', '~> 13.0' + spec.add_dependency 'sequel', '~> 5.42.0' + spec.add_dependency 'sidekiq', '~> 7.2.4' + spec.add_dependency 'sqlite3', '~> 1.4' + spec.add_dependency 'thor', '~> 1.2.1' + spec.add_dependency 'tty-markdown', '~> 0.7.1' spec.required_ruby_version = Gem::Requirement.new('~> 3.1.2') spec.metadata['homepage_uri'] = spec.homepage spec.metadata['source_code_uri'] = 'https://github.com/inferno-framework/inferno-core' diff --git a/lib/inferno/apps/cli/main.rb b/lib/inferno/apps/cli/main.rb index 2a0d25a47..8706787cd 100644 --- a/lib/inferno/apps/cli/main.rb +++ b/lib/inferno/apps/cli/main.rb @@ -133,15 +133,13 @@ def self.exit_on_failure? private # https://github.com/rubocop/rubocop/issues/12571 - still affects Ruby 3.1 upto Rubocop 1.63 - # rubocop:disable Naming/BlockForwarding - def without_bundler(&block) + def without_bundler(&) if defined?(Bundler) && ENV['BUNDLE_GEMFILE'] - Bundler.with_unbundled_env(&block) + Bundler.with_unbundled_env(&) else yield end end - # rubocop:enable Naming/BlockForwarding end end end diff --git a/lib/inferno/dsl/fhir_client_builder.rb b/lib/inferno/dsl/fhir_client_builder.rb index f723e0821..3288ea799 100644 --- a/lib/inferno/dsl/fhir_client_builder.rb +++ b/lib/inferno/dsl/fhir_client_builder.rb @@ -118,8 +118,8 @@ def headers(headers = nil) end # @private - def method_missing(name, *args, &) - return runnable.send(name, *args, &) if runnable.respond_to? name + def method_missing(name, ...) + return runnable.send(name, ...) if runnable.respond_to? name super end diff --git a/lib/inferno/dsl/http_client_builder.rb b/lib/inferno/dsl/http_client_builder.rb index 90dc02b8b..d5fd8cb32 100644 --- a/lib/inferno/dsl/http_client_builder.rb +++ b/lib/inferno/dsl/http_client_builder.rb @@ -44,8 +44,8 @@ def headers(headers = nil) end # @private - def method_missing(name, *args, &) - return runnable.send(name, *args, &) if runnable.respond_to? name + def method_missing(name, ...) + return runnable.send(name, ...) if runnable.respond_to? name super end diff --git a/lib/inferno/entities/has_runnable.rb b/lib/inferno/entities/has_runnable.rb index b358794e2..68aea7ec4 100644 --- a/lib/inferno/entities/has_runnable.rb +++ b/lib/inferno/entities/has_runnable.rb @@ -7,7 +7,7 @@ module HasRunnable def runnable return @runnable if @runnable - @runnable = (test || test_group || test_suite || load_runnable) + @runnable = test || test_group || test_suite || load_runnable end private diff --git a/lib/inferno/entities/test.rb b/lib/inferno/entities/test.rb index 997142a17..0b0ff3045 100644 --- a/lib/inferno/entities/test.rb +++ b/lib/inferno/entities/test.rb @@ -44,10 +44,10 @@ def outputs_to_persist end # @private - def method_missing(name, *args, &) + def method_missing(name, ...) parent_instance = self.class.parent&.new if parent_instance.respond_to?(name) - parent_instance.send(name, *args, &) + parent_instance.send(name, ...) else super end @@ -133,10 +133,10 @@ def test_count(_ = nil) end # @private - def method_missing(name, *args, &) + def method_missing(name, ...) parent_instance = parent&.new if parent_instance.respond_to?(name) - parent_instance.send(name, *args, &) + parent_instance.send(name, ...) else super end diff --git a/lib/inferno/entities/test_group.rb b/lib/inferno/entities/test_group.rb index ba5f7c534..78ddefe33 100644 --- a/lib/inferno/entities/test_group.rb +++ b/lib/inferno/entities/test_group.rb @@ -25,10 +25,10 @@ def initialize end # @private - def method_missing(name, *args, &) + def method_missing(name, ...) parent_instance = self.class.parent&.new if parent_instance.respond_to?(name) - parent_instance.send(name, *args, &) + parent_instance.send(name, ...) else super end diff --git a/lib/inferno/ext/fhir_models.rb b/lib/inferno/ext/fhir_models.rb index c71afd501..930c74a63 100644 --- a/lib/inferno/ext/fhir_models.rb +++ b/lib/inferno/ext/fhir_models.rb @@ -7,7 +7,7 @@ module InfernoFHIRModelExtensions attr_accessor :source_hash, :source_text def initialize(hash = {}) - super(hash) + super @source_hash = hash end @@ -26,7 +26,7 @@ class Model # allows us to call super() on from_json module InfernoJson def from_json(json) - resource = super(json) + resource = super resource&.source_text = json resource end @@ -36,7 +36,7 @@ def from_json(json) # allows us to call super() on from_xml module InfernoXml def from_xml(xml) - resource = super(xml) + resource = super resource&.source_text = xml resource end diff --git a/lib/inferno/repositories/repository.rb b/lib/inferno/repositories/repository.rb index e1edbbd2c..0a424af14 100644 --- a/lib/inferno/repositories/repository.rb +++ b/lib/inferno/repositories/repository.rb @@ -108,7 +108,7 @@ def db_params(params) end def non_db_params(params) - params.reject { |key, _value| self.class::Model.columns.include? key } + params.except(*self.class::Model.columns) end def handle_non_db_params(params) diff --git a/lib/inferno/result_summarizer.rb b/lib/inferno/result_summarizer.rb index 0ce87545e..eb91f2745 100644 --- a/lib/inferno/result_summarizer.rb +++ b/lib/inferno/result_summarizer.rb @@ -1,4 +1,4 @@ -require_relative './result_collection' +require_relative 'result_collection' module Inferno # @private # This class takes an array of results and determines the overall result. This diff --git a/lib/inferno/test_runner.rb b/lib/inferno/test_runner.rb index d44f618c5..4d3258047 100644 --- a/lib/inferno/test_runner.rb +++ b/lib/inferno/test_runner.rb @@ -1,5 +1,5 @@ -require_relative './result_summarizer' -require_relative './utils/markdown_formatter' +require_relative 'result_summarizer' +require_relative 'utils/markdown_formatter' module Inferno # @private diff --git a/lib/inferno/utils/middleware/request_logger.rb b/lib/inferno/utils/middleware/request_logger.rb index 496a9a5e6..bf6d0d0cc 100644 --- a/lib/inferno/utils/middleware/request_logger.rb +++ b/lib/inferno/utils/middleware/request_logger.rb @@ -47,7 +47,7 @@ def log_response(response, start_time, end_time, exception = nil) logger.info("#{status} in #{elapsed.in_milliseconds} ms") return unless body.present? - body = body.is_a?(Array) ? body.join : body + body = body.join if body.is_a?(Array) if body.length > 100 && !verbose_logging? logger.info("#{body[0..100]}...") diff --git a/lib/inferno/utils/preset_template_generator.rb b/lib/inferno/utils/preset_template_generator.rb index 8cceacc6e..d77fa4d19 100644 --- a/lib/inferno/utils/preset_template_generator.rb +++ b/lib/inferno/utils/preset_template_generator.rb @@ -19,7 +19,7 @@ def inputs {}.tap do |input| input[:name] = original_input.delete(:name) input[:value] = (original_input.delete(:default) if original_input.key? :default) - original_input.each { |key, value| input["_#{key}".to_sym] = value } + original_input.each { |key, value| input[:"_#{key}"] = value } end end end diff --git a/scripts/update_test_kits b/scripts/update_test_kits index 9ff455dc5..c64533f5a 100755 --- a/scripts/update_test_kits +++ b/scripts/update_test_kits @@ -18,7 +18,7 @@ require 'pry' require 'faraday' require 'json' -access_token = ENV['GITHUB_ACCESS_TOKEN'] +access_token = ENV.fetch('GITHUB_ACCESS_TOKEN', nil) test_kit_repos = [] next_link = 'https://api.github.com/orgs/inferno-framework/repos' diff --git a/spec/features_helper.rb b/spec/features_helper.rb index d35c1b283..3ee77e8fd 100644 --- a/spec/features_helper.rb +++ b/spec/features_helper.rb @@ -1,5 +1,5 @@ # Require this file for feature tests -require_relative './spec_helper' +require_relative 'spec_helper' require 'capybara' require 'capybara/rspec' diff --git a/spec/inferno/apps/cli/execute/console_outputter_spec.rb b/spec/inferno/cli/execute/console_outputter_spec.rb similarity index 97% rename from spec/inferno/apps/cli/execute/console_outputter_spec.rb rename to spec/inferno/cli/execute/console_outputter_spec.rb index 4b9092863..b82d95b38 100644 --- a/spec/inferno/apps/cli/execute/console_outputter_spec.rb +++ b/spec/inferno/cli/execute/console_outputter_spec.rb @@ -1,6 +1,6 @@ -require_relative '../../../../../lib/inferno/apps/cli/execute/console_outputter' +require_relative '../../../../lib/inferno/apps/cli/execute/console_outputter' -RSpec.describe Inferno::CLI::Execute::ConsoleOutputter do # rubocop:disable RSpec/FilePath +RSpec.describe Inferno::CLI::Execute::ConsoleOutputter do let(:instance) { described_class.new } let(:options) { { verbose: true } } diff --git a/spec/inferno/apps/cli/execute_spec.rb b/spec/inferno/cli/execute_spec.rb similarity index 92% rename from spec/inferno/apps/cli/execute_spec.rb rename to spec/inferno/cli/execute_spec.rb index 700b1ad14..9b0437505 100644 --- a/spec/inferno/apps/cli/execute_spec.rb +++ b/spec/inferno/cli/execute_spec.rb @@ -1,6 +1,6 @@ -require_relative '../../../../lib/inferno/apps/cli/execute' +require_relative '../../../lib/inferno/apps/cli/execute' -RSpec.describe Inferno::CLI::Execute do # rubocop:disable RSpec/FilePath +RSpec.describe Inferno::CLI::Execute do let(:instance) { described_class.new } describe '.suppress_output' do @@ -95,8 +95,8 @@ describe '#test_session' do it 'returns test session given suite options' do - allow(instance).to receive(:options).and_return({ suite: 'basic', suite_options: { option: 'a' } }) - allow(instance).to receive(:suite).and_return(BasicTestSuite::Suite) + allow(instance).to receive_messages(options: { suite: 'basic', suite_options: { option: 'a' } }, + suite: BasicTestSuite::Suite) expect(instance.test_session).to be_instance_of Inferno::Entities::TestSession end end @@ -108,8 +108,7 @@ let(:inputs_array) { [{ name: :url, value: 'https://example.com' }] } it 'returns test run params' do - allow(instance).to receive(:options).and_return({ suite: test_suite.id, inputs: inputs_hash }) - allow(instance).to receive(:runnable_type).and_return(:suite) + allow(instance).to receive_messages(options: { suite: test_suite.id, inputs: inputs_hash }, runnable_type: :suite) result = instance.create_params(test_session, test_suite) expect(result).to eq({ test_session_id: test_session.id, test_suite_id: test_suite.id, inputs: inputs_array }) @@ -121,8 +120,7 @@ let(:test_run) { repo_create(:test_run, test_suite_id: 'basic') } it 'supresses output if verbose is false' do - allow(instance).to receive(:test_session).and_return(test_session) - allow(instance).to receive(:options).and_return({ suite: 'basic', verbose: false }) + allow(instance).to receive_messages(test_session:, options: { suite: 'basic', verbose: false }) expect { instance.dispatch_job(test_run) }.to_not output(/.+/).to_stdout_from_any_process end diff --git a/spec/inferno/apps/cli/main_spec.rb b/spec/inferno/cli/main_spec.rb similarity index 80% rename from spec/inferno/apps/cli/main_spec.rb rename to spec/inferno/cli/main_spec.rb index 435e33787..91e16b7d2 100644 --- a/spec/inferno/apps/cli/main_spec.rb +++ b/spec/inferno/cli/main_spec.rb @@ -3,7 +3,7 @@ require 'inferno/apps/cli/main' require 'inferno/version' -RSpec.describe Inferno::CLI::Main do # rubocop:disable RSpec/FilePath +RSpec.describe Inferno::CLI::Main do context 'with version command' do it 'outputs current Inferno version' do expect { described_class.new.version }.to output("Inferno Core v#{Inferno::VERSION}\n").to_stdout diff --git a/spec/inferno/apps/cli/new_spec.rb b/spec/inferno/cli/new_spec.rb similarity index 91% rename from spec/inferno/apps/cli/new_spec.rb rename to spec/inferno/cli/new_spec.rb index b3544075e..2641174c4 100644 --- a/spec/inferno/apps/cli/new_spec.rb +++ b/spec/inferno/cli/new_spec.rb @@ -1,9 +1,9 @@ require 'rspec' require 'inferno/apps/cli/new' -PACKAGE_FIXTURE = File.expand_path('../../../fixtures/small_package.tgz', __dir__) +PACKAGE_FIXTURE = File.expand_path('../../fixtures/small_package.tgz', __dir__) -RSpec.describe Inferno::CLI::New do # rubocop:disable RSpec/FilePath +RSpec.describe Inferno::CLI::New do around do |test| Dir.mktmpdir do |tmpdir| FileUtils.chdir(tmpdir) do diff --git a/spec/inferno/dsl/assertions_spec.rb b/spec/inferno/dsl/assertions_spec.rb index 1035f1618..29e60a9df 100644 --- a/spec/inferno/dsl/assertions_spec.rb +++ b/spec/inferno/dsl/assertions_spec.rb @@ -46,7 +46,9 @@ context 'when a response is provided' do context 'with a single status' do it 'does not raise an exception if the response matches the status' do - klass.assert_response_status(200, response: { status: 200 }) + expect do + klass.assert_response_status(200, response: { status: 200 }) + end.to_not raise_error end it 'raises an exception if the response does not match the status' do @@ -59,7 +61,9 @@ context 'with an array of statuses' do it 'does not raise an exception if the response matches a status' do - klass.assert_response_status([100, 200, 300], response: { status: 200 }) + expect do + klass.assert_response_status([100, 200, 300], response: { status: 200 }) + end.to_not raise_error end it 'raises an exception if the response does not match the status' do @@ -107,7 +111,9 @@ def klass.request describe '#assert_resource_type' do context 'when a resource is provided' do it 'does not raise an exception if the resource matches the type' do - klass.assert_resource_type('CarePlan', resource: care_plan_resource) + expect do + klass.assert_resource_type('CarePlan', resource: care_plan_resource) + end.to_not raise_error end it 'raises an exception if the resource does not match the type' do diff --git a/spec/inferno/dsl/configurable_spec.rb b/spec/inferno/dsl/configurable_spec.rb index a8785b717..d1ea06577 100644 --- a/spec/inferno/dsl/configurable_spec.rb +++ b/spec/inferno/dsl/configurable_spec.rb @@ -81,7 +81,7 @@ def self.all_children identifier = :input1 input = { type: 'textarea' } config.add_input(identifier, input) - expected_input = Inferno::Entities::Input.new(**{ name: :input1 }.merge(input)) + expected_input = Inferno::Entities::Input.new(name: :input1, **input) expect(config.input(identifier)).to eq(expected_input) end diff --git a/spec/inferno/dsl/fhir_client_spec.rb b/spec/inferno/dsl/fhir_client_spec.rb index 38c355357..ed62a518c 100644 --- a/spec/inferno/dsl/fhir_client_spec.rb +++ b/spec/inferno/dsl/fhir_client_spec.rb @@ -360,8 +360,7 @@ def test_session_id context 'with oauth_credentials' do it 'performs a refresh if the token is about to expire' do client = group.fhir_client(:client_with_oauth_credentials) - allow(client).to receive(:need_to_refresh?).and_return(true) - allow(client).to receive(:able_to_refresh?).and_return(true) + allow(client).to receive_messages(need_to_refresh?: true, able_to_refresh?: true) allow(group).to receive(:perform_refresh).with(client) group.fhir_operation(path, client: :client_with_oauth_credentials) @@ -374,8 +373,7 @@ def test_session_id context 'with auth info' do it 'performs a refresh if the token is about to expire' do client = group.fhir_client(:client_with_auth_info) - allow(client).to receive(:need_to_refresh?).and_return(true) - allow(client).to receive(:able_to_refresh?).and_return(true) + allow(client).to receive_messages(need_to_refresh?: true, able_to_refresh?: true) allow(group).to receive(:perform_refresh).with(client) group.fhir_operation(path, client: :client_with_auth_info) @@ -544,8 +542,7 @@ def test_session_id context 'with oauth_credentials' do it 'performs a refresh if the token is about to expire' do client = group.fhir_client(:client_with_oauth_credentials) - allow(client).to receive(:need_to_refresh?).and_return(true) - allow(client).to receive(:able_to_refresh?).and_return(true) + allow(client).to receive_messages(need_to_refresh?: true, able_to_refresh?: true) allow(group).to receive(:perform_refresh).with(client) group.fhir_read(resource.resourceType, resource_id, client: :client_with_oauth_credentials) @@ -558,8 +555,7 @@ def test_session_id context 'with auth info' do it 'performs a refresh if the token is about to expire' do client = group.fhir_client(:client_with_auth_info) - allow(client).to receive(:need_to_refresh?).and_return(true) - allow(client).to receive(:able_to_refresh?).and_return(true) + allow(client).to receive_messages(need_to_refresh?: true, able_to_refresh?: true) allow(group).to receive(:perform_refresh).with(client) group.fhir_read(resource.resourceType, resource_id, client: :client_with_auth_info) @@ -1079,8 +1075,7 @@ def test_session_id it 'performs a refresh if the token is about to expire' do stub_get_search_request client = group.fhir_client(:client_with_oauth_credentials) - allow(client).to receive(:need_to_refresh?).and_return(true) - allow(client).to receive(:able_to_refresh?).and_return(true) + allow(client).to receive_messages(need_to_refresh?: true, able_to_refresh?: true) allow(group).to receive(:perform_refresh).with(client) group.fhir_search(resource.resourceType, params: { patient: 123 }, client: :client_with_oauth_credentials) @@ -1094,8 +1089,7 @@ def test_session_id it 'performs a refresh if the token is about to expire' do stub_get_search_request client = group.fhir_client(:client_with_auth_info) - allow(client).to receive(:need_to_refresh?).and_return(true) - allow(client).to receive(:able_to_refresh?).and_return(true) + allow(client).to receive_messages(need_to_refresh?: true, able_to_refresh?: true) allow(group).to receive(:perform_refresh).with(client) group.fhir_search(resource.resourceType, params: { patient: 123 }, client: :client_with_auth_info) diff --git a/spec/inferno/dsl/input_output_handling_spec.rb b/spec/inferno/dsl/input_output_handling_spec.rb index 0477f340c..e85916b78 100644 --- a/spec/inferno/dsl/input_output_handling_spec.rb +++ b/spec/inferno/dsl/input_output_handling_spec.rb @@ -129,16 +129,16 @@ v2_option = Inferno::DSL::SuiteOption.new(id: :ig_version, value: '2') missing_inputs = suite.missing_inputs([{ name: 'v1_input', value: 'abc' }], nil) - expect(missing_inputs).to match_array(['v2_input', 'all_versions_input']) + expect(missing_inputs).to contain_exactly('v2_input', 'all_versions_input') missing_inputs = suite.missing_inputs([{ name: 'v1_input', value: 'abc' }], [v1_option]) - expect(missing_inputs).to match_array(['all_versions_input']) + expect(missing_inputs).to contain_exactly('all_versions_input') missing_inputs = suite.missing_inputs([{ name: 'v1_input', value: 'abc' }], [v2_option]) - expect(missing_inputs).to match_array(['v2_input', 'all_versions_input']) + expect(missing_inputs).to contain_exactly('v2_input', 'all_versions_input') missing_inputs = suite.missing_inputs([{ name: 'v2_input', value: 'abc' }], [v1_option]) - expect(missing_inputs).to match_array(['v1_input', 'all_versions_input']) + expect(missing_inputs).to contain_exactly('v1_input', 'all_versions_input') end end diff --git a/spec/inferno/dsl/test_creation_spec.rb b/spec/inferno/dsl/test_creation_spec.rb index 6f3ca2264..f936e4abe 100644 --- a/spec/inferno/dsl/test_creation_spec.rb +++ b/spec/inferno/dsl/test_creation_spec.rb @@ -1,5 +1,3 @@ -# rubocop:disable RSpec/FilePath - RSpec.describe InfrastructureTest::Suite do let(:suite) { described_class } let(:test_run) { Inferno::Entities::TestRun.new(id: SecureRandom.uuid) } @@ -57,11 +55,11 @@ end it 'contains the correct inputs' do - expect(suite.inputs).to match_array([:suite_input]) + expect(suite.inputs).to contain_exactly(:suite_input) end it 'contains the correct outputs' do - expect(suite.outputs).to match_array([:suite_output]) + expect(suite.outputs).to contain_exactly(:suite_output) end it 'contains the correct groups' do @@ -140,15 +138,15 @@ end it "contains its own inputs as well as its parents' inputs" do - expect(outer_inline_group.inputs).to match_array([:suite_input, :outer_group_input]) + expect(outer_inline_group.inputs).to contain_exactly(:suite_input, :outer_group_input) end it "contains its own outputs as well as its parents' outputs" do - expect(outer_inline_group.outputs).to match_array([:suite_output, :outer_group_output]) + expect(outer_inline_group.outputs).to contain_exactly(:suite_output, :outer_group_output) end it 'contains the correct groups' do - expect(outer_inline_group.groups).to match_array([inner_inline_group]) + expect(outer_inline_group.groups).to contain_exactly(inner_inline_group) end it 'contains groups with correct short_ids' do @@ -209,15 +207,15 @@ end it "contains its own inputs as well as its parents' inputs" do - expect(inner_inline_group.inputs).to match_array([:suite_input, :outer_group_input, :inner_group_input]) + expect(inner_inline_group.inputs).to contain_exactly(:suite_input, :outer_group_input, :inner_group_input) end it "contains its own outputs as well as its parents' outputs" do - expect(inner_inline_group.outputs).to match_array([:suite_output, :outer_group_output, :inner_group_output]) + expect(inner_inline_group.outputs).to contain_exactly(:suite_output, :outer_group_output, :inner_group_output) end it 'contains the correct groups' do - expect(inner_inline_group.groups).to match_array([]) + expect(inner_inline_group.groups).to be_empty end it 'contains the correct tests' do @@ -347,11 +345,11 @@ end it "contains its own inputs as well as its parents' inputs" do - expect(external_outer_group.inputs).to match_array([:suite_input, :external_outer_group_input]) + expect(external_outer_group.inputs).to contain_exactly(:suite_input, :external_outer_group_input) end it "contains its own outputs as well as its parents' outputs" do - expect(external_outer_group.outputs).to match_array([:suite_output, :external_outer_group_output]) + expect(external_outer_group.outputs).to contain_exactly(:suite_output, :external_outer_group_output) end it 'contains the correct short_id' do @@ -372,7 +370,7 @@ end it "contains its own fhir clients as well as its parents' fhir clients" do - expect(external_outer_group.fhir_client_definitions.keys).to match_array([:suite, :external_outer_group]) + expect(external_outer_group.fhir_client_definitions.keys).to contain_exactly(:suite, :external_outer_group) end it 'passes' do @@ -564,5 +562,3 @@ end end end - -# rubocop:enable RSpec/FilePath diff --git a/spec/inferno/repositories/validator_sessions_spec.rb b/spec/inferno/repositories/validator_sessions_spec.rb index fdea4493b..af97c39cc 100644 --- a/spec/inferno/repositories/validator_sessions_spec.rb +++ b/spec/inferno/repositories/validator_sessions_spec.rb @@ -2,39 +2,39 @@ let(:repo) { described_class.new } let(:validator_name) { 'basic_name' } let(:test_suite_id) { 'basic_suite' } - let(:validator_session_id1) { 'basic_validator1' } - let(:validator_session_id2) { 'basic_validator2' } - let(:validator_session_id3) { 'basic_validator3' } - let(:suite_options1) { { ig_version: '1', us_core_version: '4' } } - let(:suite_options2) { { ig_version: '2' } } + let(:first_validator_session_id) { 'basic_validator1' } + let(:second_validator_session_id) { 'basic_validator2' } + let(:third_validator_session_id) { 'basic_validator3' } + let(:first_suite_options) { { ig_version: '1', us_core_version: '4' } } + let(:second_suite_options) { { ig_version: '2' } } let(:suite_options_alt) { { us_core_version: '4', ig_version: '1' } } let(:session1_params) do { - validator_session_id: validator_session_id1, + validator_session_id: first_validator_session_id, validator_name:, test_suite_id:, - suite_options: suite_options1 + suite_options: first_suite_options } end let(:session2_params) do { - validator_session_id: validator_session_id2, + validator_session_id: second_validator_session_id, validator_name:, test_suite_id:, - suite_options: suite_options2 + suite_options: second_suite_options } end let(:session3_params) do { - validator_session_id: validator_session_id3, + validator_session_id: third_validator_session_id, validator_name:, test_suite_id:, - suite_options: suite_options1 + suite_options: first_suite_options } end let(:session_params_alt_options) do { - validator_session_id: validator_session_id2, + validator_session_id: second_validator_session_id, validator_name:, test_suite_id:, suite_options: suite_options_alt @@ -42,18 +42,18 @@ end let(:session_params_alt_name) do { - validator_session_id: validator_session_id2, + validator_session_id: second_validator_session_id, validator_name: 'alt name', test_suite_id:, - suite_options: suite_options1 + suite_options: first_suite_options } end let(:session_params_alt_id) do { - validator_session_id: validator_session_id2, + validator_session_id: second_validator_session_id, validator_name:, test_suite_id: 'alt id', - suite_options: suite_options1 + suite_options: first_suite_options } end @@ -66,7 +66,7 @@ it 'persists data' do record = repo.db.first expect(repo.db.count).to eq(1) - expect(record[:validator_session_id]).to eq(validator_session_id1) + expect(record[:validator_session_id]).to eq(first_validator_session_id) expect(record[:validator_name]).to eq(validator_name) expect(record[:test_suite_id]).to eq(test_suite_id) end @@ -75,7 +75,7 @@ repo.save(session2_params) record = repo.db.all[1] expect(repo.db.count).to eq(2) - expect(record[:validator_session_id]).to eq(validator_session_id2) + expect(record[:validator_session_id]).to eq(second_validator_session_id) expect(record[:validator_name]).to eq(validator_name) expect(record[:test_suite_id]).to eq(test_suite_id) end @@ -84,7 +84,7 @@ repo.save(session3_params) record = repo.db.first expect(repo.db.count).to eq(1) - expect(record[:validator_session_id]).to eq(validator_session_id3) + expect(record[:validator_session_id]).to eq(third_validator_session_id) expect(record[:validator_name]).to eq('basic_name') expect(record[:test_suite_id]).to eq(test_suite_id) end @@ -114,9 +114,9 @@ validator_id_alt = repo.find_validator_session_id(session_params_alt_options[:test_suite_id], session_params_alt_options[:validator_name], session_params_alt_options[:suite_options]) - expect(validator_session_id2).to eq(validator_id) - expect(validator_session_id2).to eq(validator_id_alt) - expect(validator_session_id2).to eq(record[:validator_session_id]) + expect(second_validator_session_id).to eq(validator_id) + expect(second_validator_session_id).to eq(validator_id_alt) + expect(second_validator_session_id).to eq(record[:validator_session_id]) end it 'saves two records and finds the correct one, discriminating by suite options' do diff --git a/spec/inferno/result_collection_spec.rb b/spec/inferno/result_collection_spec.rb index e4f766c6d..66c2e74e4 100644 --- a/spec/inferno/result_collection_spec.rb +++ b/spec/inferno/result_collection_spec.rb @@ -52,23 +52,23 @@ end describe '#<<' do - let(:new_result1) { repo_create(:result, result: 'pass') } - let(:new_result2) { repo_create(:result, result: 'fail') } + let(:first_result) { repo_create(:result, result: 'pass') } + let(:second_result) { repo_create(:result, result: 'fail') } it 'adds a new result to the collection' do - expect { result_collection << new_result1 }.to change { result_collection.results.size }.by(1) - expect(result_collection.results).to include(new_result1) + expect { result_collection << first_result }.to change { result_collection.results.size }.by(1) + expect(result_collection.results).to include(first_result) end it 'flattens the results array after adding a new result' do - nested_results = [new_result1, new_result2] + nested_results = [first_result, second_result] expect { result_collection << nested_results }.to change { result_collection.results.size }.by(2) expect(result_collection.results).to include(*nested_results) expect(result_collection.results.flatten!).to be_nil end it 'returns the ResultCollection instance itself after adding a result' do - result = result_collection << new_result1 + result = result_collection << first_result expect(result).to eq(result_collection) end end diff --git a/spec/inferno/utils/ig_downloader_spec.rb b/spec/inferno/utils/ig_downloader_spec.rb index 45de7eb02..2e77e33ae 100644 --- a/spec/inferno/utils/ig_downloader_spec.rb +++ b/spec/inferno/utils/ig_downloader_spec.rb @@ -5,7 +5,7 @@ def with_temp_path(name) path = File.join(Inferno::Application.root, 'tmp', "rspec-#{name.sum}.tmp") yield(path) - File.delete(path) if File.exist?(path) + FileUtils.rm_f(path) end RSpec.describe Inferno::Utils::IgDownloader do diff --git a/spec/inferno/utils/named_thor_actions_spec.rb b/spec/inferno/utils/named_thor_actions_spec.rb index 5d4d8cfca..8e697beb9 100644 --- a/spec/inferno/utils/named_thor_actions_spec.rb +++ b/spec/inferno/utils/named_thor_actions_spec.rb @@ -9,7 +9,7 @@ end %w[test_fhir_app test-fhir-app TestFhirApp testFhir_app].each do |name| - context "given name #{name}" do + context "when given name #{name}" do let(:dummy) do dummy_instance = dummy_class.new dummy_instance.name = name diff --git a/spec/inferno/web/serializers/test_group_spec.rb b/spec/inferno/web/serializers/test_group_spec.rb index 03b1fd0f3..a71e490f7 100644 --- a/spec/inferno/web/serializers/test_group_spec.rb +++ b/spec/inferno/web/serializers/test_group_spec.rb @@ -37,7 +37,7 @@ expect(serialized_group['test_groups']).to be_empty expect(serialized_group['tests'].length).to eq(group.tests.length) - group.available_inputs.each do |_identifier, definition| + group.available_inputs.each_value do |definition| raw_input = serialized_group['inputs'] .find { |serialized_input| serialized_input['name'] == definition.name } .symbolize_keys @@ -49,7 +49,7 @@ expect(input).to eq(definition) end - group.output_definitions.each do |_identifier, definition| + group.output_definitions.each_value do |definition| output = serialized_group['outputs'] .find { |serialized_output| serialized_output['name'] == definition[:name].to_s } diff --git a/spec/inferno/web/serializers/test_spec.rb b/spec/inferno/web/serializers/test_spec.rb index 926c05c5c..026e7e53a 100644 --- a/spec/inferno/web/serializers/test_spec.rb +++ b/spec/inferno/web/serializers/test_spec.rb @@ -21,7 +21,7 @@ expect(serialized_test['inputs'].length).to eq(test.inputs.length) expect(serialized_test['outputs'].length).to eq(test.outputs.length) - test.available_inputs.each do |_identifier, definition| + test.available_inputs.each_value do |definition| raw_input = serialized_test['inputs'] .find { |serialized_input| serialized_input['name'] == definition.name } .symbolize_keys @@ -33,7 +33,7 @@ expect(input).to eq(definition) end - test.output_definitions.each do |_identifier, definition| + test.output_definitions.each_value do |definition| output = serialized_test['outputs'] .find { |serialized_output| serialized_output['name'] == definition[:name].to_s }