New rule: RedundantNext

closes #131
This commit is contained in:
Vitalii Elenhaupt 2020-03-24 18:01:23 +02:00
parent 946ec67fae
commit a5dd07e9e4
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
7 changed files with 355 additions and 43 deletions

View file

@ -0,0 +1,26 @@
require "../../../spec_helper"
module Ameba::AST
source = Source.new ""
rule = RedundantControlExpressionRule.new
describe RedundantControlExpressionVisitor do
node = as_node %(
a = 1
b = 2
return a + b
)
subject = RedundantControlExpressionVisitor.new(rule, source, node)
it "assigns valid attributes" do
subject.rule.should eq rule
subject.source.should eq source
subject.node.should eq node
end
it "fires a callback with a valid node" do
rule.nodes.size.should eq 1
rule.nodes.first.to_s.should eq "return a + b"
end
end
end