Skip to content

Commit

Permalink
Remove useless TARGET_RUBY_VERSION env var
Browse files Browse the repository at this point in the history
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
  • Loading branch information
koic authored and bbatsov committed Feb 27, 2024
1 parent 49b135b commit 91a4226
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/rubocop.yml
Expand Up @@ -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: >-
Expand Down
4 changes: 0 additions & 4 deletions Rakefile
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -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
Expand Down

0 comments on commit 91a4226

Please sign in to comment.