diff --git a/spec/shared_contexts.rb b/spec/shared_contexts.rb new file mode 100644 index 0000000..d7078b3 --- /dev/null +++ b/spec/shared_contexts.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +RSpec.shared_context 'ruby 2.7' do + # Prism supports parsing Ruby 3.3+. + let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 2.7 } +end + +RSpec.shared_context 'ruby 3.0' do + # Prism supports parsing Ruby 3.3+. + let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 3.0 } +end + +RSpec.shared_context 'ruby 3.1' do + # Prism supports parsing Ruby 3.3+. + let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 3.1 } +end + +RSpec.shared_context 'ruby 3.2' do + # Prism supports parsing Ruby 3.3+. + let(:ruby_version) { ENV['PARSER_ENGINE'] == 'parser_prism' ? 3.3 : 3.2 } +end + +RSpec.shared_context 'ruby 3.3' do + let(:ruby_version) { 3.3 } +end + +RSpec.shared_context 'ruby 3.4' do + let(:ruby_version) { 3.4 } +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0eaadf4..2c6f662 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -18,6 +18,7 @@ require 'rubocop-thread_safety' require 'rubocop/rspec/support' +require_relative 'shared_contexts' RSpec.configure do |config| config.include RuboCop::RSpec::ExpectOffense