From 1d827b4969131d057670e4e45f0043f86e5f0745 Mon Sep 17 00:00:00 2001 From: Vitalii Elenhaupt Date: Wed, 25 Mar 2020 18:14:15 +0200 Subject: [PATCH] Add specs for COMMENT_DIRECTIVE_REGEX --- spec/ameba/inline_comments_spec.cr | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/ameba/inline_comments_spec.cr b/spec/ameba/inline_comments_spec.cr index 7b2ba362..593a6fc2 100644 --- a/spec/ameba/inline_comments_spec.cr +++ b/spec/ameba/inline_comments_spec.cr @@ -2,6 +2,24 @@ require "../spec_helper" module Ameba describe InlineComments do + describe InlineComments::COMMENT_DIRECTIVE_REGEX do + subject = InlineComments::COMMENT_DIRECTIVE_REGEX + + it "allows to parse action and rule name" do + result = subject.match("#ameba:enable Group/RuleName") + result.should_not be_nil + result.not_nil![1].should eq "enable" + result.not_nil![2].should eq "Group/RuleName" + end + + it "ignores the repeatable spaces" do + result = subject.match("# ameba : enable Group/RuleName") + result.should_not be_nil + result.not_nil![1].should eq "enable" + result.not_nil![2].should eq "Group/RuleName" + end + end + it "disables a rule with a comment directive" do s = Source.new %Q( # ameba:disable #{NamedRule.name}