Skip to content

Commit

Permalink
Merge pull request #110 from rubocop/support_prism
Browse files Browse the repository at this point in the history
Add job for CI using Prism parser
  • Loading branch information
ydah authored Apr 8, 2024
2 parents 866f2b2 + de6e47f commit 3ee2486
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,24 @@ jobs:
ruby-version: "3.3"
bundler-cache: true
- run: NO_COVERAGE=true bundle exec rake ${{ matrix.task }}

prism:
runs-on: ubuntu-latest
name: Prism
steps:
- uses: actions/checkout@v4
- name: Use prism parser
run: |
cat << EOF > Gemfile.local
gem 'prism'
EOF
- name: set up Ruby
uses: ruby/setup-ruby@v1
with:
# Specify the minimum Ruby version 2.7 required for Prism to run.
ruby-version: 2.7
bundler-cache: true
- name: spec
env:
PARSER_ENGINE: parser_prism
run: NO_COVERAGE=true bundle exec rake
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@
end

%w[&& ||].each do |operator|
context "with #{operator}" do
# FIXME: `undefined method `[]' for nil` occurs Prism 0.24.0.
# It has been resolved in the development line.
# This will be resolved in Prism > 0.24.0 and higher releases.
context "with #{operator}", broken_on: :prism do
it 'does not flag the call' do
expect_no_offenses(<<~RUBY)
can_create_user? #{operator} create(:user)
Expand All @@ -210,7 +213,10 @@
end
end

context 'with ternary operator' do
# FIXME: `undefined method `[]' for nil` occurs Prism 0.24.0.
# It has been resolved in the development line.
# This will be resolved in Prism > 0.24.0 and higher releases.
context 'with ternary operator', broken_on: :prism do
it 'does not flag the call' do
expect_no_offenses(<<~RUBY)
can_create_user? ? create(:user) : nil
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ module SpecHelper
# Run focused tests with `fdescribe`, `fit`, `:focus` etc.
config.filter_run_when_matching :focus

if ENV['PARSER_ENGINE'] == 'parser_prism'
config.filter_run_excluding broken_on: :prism
end

# We should address configuration warnings when we upgrade
config.raise_errors_for_deprecations!

Expand Down

0 comments on commit 3ee2486

Please sign in to comment.