Skip to content

Commit

Permalink
Move test Node#used? predicate method definition
Browse files Browse the repository at this point in the history
Definining a method in a `before :all` block doesn't clean it up
automatically, meaning once we've defined it, it's there for all
remaining tests.

Since it leaks anyway, we can just define it at the top of the file, and
avoid needing to disable `ConstantDefinitionInBlock`.
  • Loading branch information
sambostock authored and marcandre committed Aug 5, 2024
1 parent 6be2d59 commit 6ab3248
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions spec/rubocop/ast/node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@

require 'uri'

module RuboCop
module AST
# Patch Node
class Node
# Let's make our predicate matchers read better
def used?
value_used?
end
end
end
end

RSpec.describe RuboCop::AST::Node do
let(:ast) { parse_source(src).node }
let(:node) { ast }

describe '#value_used?' do
before :all do
module RuboCop # rubocop:disable Lint/ConstantDefinitionInBlock
module AST
# Patch Node
class Node
# Let's make our predicate matchers read better
def used?
value_used?
end
end
end
end
end

context 'at the top level' do
let(:src) { 'expr' }

Expand Down

0 comments on commit 6ab3248

Please sign in to comment.