Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore skipped specs for Prism #1275

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions spec/rubocop/cop/rails/blank_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

RSpec.describe RuboCop::Cop::Rails::Blank, :config do
shared_examples 'offense' do |source, correction, message|
# 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.
it 'registers an offense and corrects', broken_on: :prism do
it 'registers an offense and corrects' do
expect_offense(<<~RUBY, source: source, message: message)
#{source}
^{source} #{message}
Expand Down
4 changes: 1 addition & 3 deletions spec/rubocop/cop/rails/exit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
RUBY
end

# 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.
it 'registers an offense for an exit! call with no receiver', broken_on: :prism do
it 'registers an offense for an exit! call with no receiver' do
expect_offense(<<~RUBY)
exit!
^^^^^ Do not use `exit` in Rails applications.
Expand Down
4 changes: 1 addition & 3 deletions spec/rubocop/cop/rails/present_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

RSpec.describe RuboCop::Cop::Rails::Present, :config do
shared_examples 'offense' do |source, correction, message|
# 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.
it 'registers an offense and corrects', broken_on: :prism do
it 'registers an offense and corrects' do
expect_offense(<<~RUBY, source: source, message: message)
#{source}
^{source} #{message}
Expand Down
7 changes: 1 addition & 6 deletions spec/rubocop/cop/rails/safe_navigation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,7 @@
it_behaves_like 'autocorrect', 'try! with 2 parameters', '[1, 2].try!(:join, ",")', '[1, 2]&.join(",")'
it_behaves_like 'autocorrect', 'try! with multiple parameters',
'[1, 2].try!(:join, bar, baz)', '[1, 2]&.join(bar, baz)'
# 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 'skip test when parser engine is prism', broken_on: :prism do
it_behaves_like 'autocorrect', 'try! without receiver', 'try!(:join)', 'self&.join'
end

it_behaves_like 'autocorrect', 'try! without receiver', 'try!(:join)', 'self&.join'
it_behaves_like 'autocorrect', 'try! with a block',
['[foo, bar].try!(:map) do |e|',
' e.some_method',
Expand Down
4 changes: 1 addition & 3 deletions spec/rubocop/cop/rails/save_bang_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@
end
end

# 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.
it "when using #{method} without arguments", broken_on: :prism do
it "when using #{method} without arguments" do
expect_offense(<<~RUBY, method: method)
#{method}
^{method} Use `#{method}!` instead of `#{method}` if the return value is not checked.
Expand Down
12 changes: 3 additions & 9 deletions spec/rubocop/cop/rails/skips_model_validations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,21 @@
RUBY
end

# 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.
it "registers an offense for #{method} with `:returning` keyword argument", broken_on: :prism do
it "registers an offense for #{method} with `:returning` keyword argument" do
expect_offense(<<~RUBY, method: method)
%{method}(attributes, returning: false)
^{method} Avoid using `#{method}` because it skips validations.
RUBY
end

# 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.
it "registers an offense for #{method} with `:unique_by` keyword argument", broken_on: :prism do
it "registers an offense for #{method} with `:unique_by` keyword argument" do
expect_offense(<<~RUBY, method: method)
%{method}(attributes, unique_by: :username)
^{method} Avoid using `#{method}` because it skips validations.
RUBY
end

# 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.
it "registers an offense for #{method} with both `:returning` and `:unique_by` keyword arguments", broken_on: :prism do # rubocop:disable Layout/LineLength
it "registers an offense for #{method} with both `:returning` and `:unique_by` keyword arguments" do
expect_offense(<<~RUBY, method: method)
%{method}(attributes, returning: false, unique_by: :username)
^{method} Avoid using `#{method}` because it skips validations.
Expand Down
8 changes: 2 additions & 6 deletions spec/rubocop/cop/rails/where_exists_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@
RUBY
end

# 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.
it 'registers an offense when using implicit receiver and arg', broken_on: :prism do
it 'registers an offense when using implicit receiver and arg' do
expect_offense(<<~RUBY)
where('name = ?', 'john').exists?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `exists?(['name = ?', 'john'])` over `where('name = ?', 'john').exists?`.
Expand Down Expand Up @@ -155,9 +153,7 @@
RUBY
end

# 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.
it 'registers an offense when using implicit receiver and arg', broken_on: :prism do
it 'registers an offense when using implicit receiver and arg' do
expect_offense(<<~RUBY)
exists?('name = ?', 'john')
^^^^^^^^^^^^^^^^^^^^^^^^^^^ Prefer `where('name = ?', 'john').exists?` over `exists?('name = ?', 'john')`.
Expand Down