shard-ameba/spec/ameba/ast/visitors/redundant_control_expression_visitor_spec.cr

27 lines
632 B
Crystal
Raw Normal View History

2020-03-24 16:01:23 +00:00
require "../../../spec_helper"
module Ameba::AST
source = Source.new ""
rule = RedundantControlExpressionRule.new
describe RedundantControlExpressionVisitor do
2022-12-19 17:03:11 +00:00
node = as_node <<-CRYSTAL
2020-03-24 16:01:23 +00:00
a = 1
b = 2
return a + b
2022-12-19 17:03:11 +00:00
CRYSTAL
2020-03-24 16:01:23 +00:00
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