From 91a422612bca76cb8b427303ffd458e3f381af86 Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Tue, 27 Feb 2024 21:56:57 +0900 Subject: [PATCH] Remove useless `TARGET_RUBY_VERSION` env var This PR removes useless `TARGET_RUBY_VERSION` env var and uses `PARSER_ENGINE` env var instead. In fact, the `ruby_version` in `shared_context` is replaced with the value required by `PARSER_ENGINE`: https://github.com/rubocop/rubocop-ast/blob/49b135be4a4edce97955a1e987d50a295f72a907/spec/spec_helper.rb#L22-L60 --- .github/workflows/rubocop.yml | 2 -- Rakefile | 4 ---- spec/spec_helper.rb | 3 ++- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 9c6c7b04a..019fd0164 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -89,9 +89,7 @@ jobs: bundler-cache: true - name: spec env: - # Specify the minimum Ruby version 3.3 required for Prism to analyze. PARSER_ENGINE: parser_prism - TARGET_RUBY_VERSION: 3.3 run: bundle exec rake prism_spec rubocop_specs: name: >- diff --git a/Rakefile b/Rakefile index bf961497f..c64829799 100644 --- a/Rakefile +++ b/Rakefile @@ -25,18 +25,14 @@ end desc 'Run RSpec code examples with Prism' task prism_spec: :generate do original_parser_engine = ENV.fetch('PARSER_ENGINE', nil) - original_target_ruby_version = ENV.fetch('TARGET_RUBY_VERSION', nil) RSpec::Core::RakeTask.new(prism_spec: :generate) do |spec| - # Specify the minimum Ruby version 3.3 required for Prism to analyze. ENV['PARSER_ENGINE'] = 'parser_prism' - ENV['TARGET_RUBY_VERSION'] = '3.3' spec.pattern = FileList['spec/**/*_spec.rb'] end ENV['PARSER_ENGINE'] = original_parser_engine - ENV['TARGET_RUBY_VERSION'] = original_target_ruby_version end desc 'Run RSpec with code coverage' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4d27e4a56..048c0631e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -71,7 +71,8 @@ module DefaultRubyVersion extend RSpec::SharedContext - let(:ruby_version) { ENV.fetch('TARGET_RUBY_VERSION', 2.4).to_f } + # The minimum version Prism can parse is 3.3. + let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.4 } end module DefaultParserEngine