Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-05-21 16:56:10 +0300
committerJan Provaznik <jprovaznik@gitlab.com>2019-05-21 16:56:10 +0300
commite556b421c503a067908d6937a2deb74310037a29 (patch)
treea4c5589ef29ea5adbc2fb02050e1325020aaf762 /spec
parent4cf3a176da199b3f1fd874b3ba118e0ca2495939 (diff)
parent95afdfaeeb301699df3bbac0fde9cad0dda4d5f1 (diff)
Merge branch 'haml-lint-no-plain-nodes' into 'master'
Add HamlLint::Linter::NoPlainNodes linter See merge request gitlab-org/gitlab-ce!28265
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/haml_lint/linter/no_plain_nodes_spec.rb55
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/lib/haml_lint/linter/no_plain_nodes_spec.rb b/spec/lib/haml_lint/linter/no_plain_nodes_spec.rb
new file mode 100644
index 00000000000..99cc9b9bc8d
--- /dev/null
+++ b/spec/lib/haml_lint/linter/no_plain_nodes_spec.rb
@@ -0,0 +1,55 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require 'haml_lint'
+require 'haml_lint/spec'
+
+describe HamlLint::Linter::NoPlainNodes do
+ include_context 'linter'
+
+ context 'reports when a tag has an inline plain node' do
+ let(:haml) { '%tag Hello Tanuki' }
+ let(:message) { "`Hello Tanuki` is a plain node. Please use an i18n method like `= _('Hello Tanuki')`" }
+
+ it { is_expected.to report_lint message: message }
+ end
+
+ context 'reports when a tag has multiline plain nodes' do
+ let(:haml) { <<-HAML }
+ %tag
+ Hello
+ Tanuki
+ HAML
+
+ it { is_expected.to report_lint count: 1 }
+ end
+
+ context 'reports when a tag has an inline plain node with interpolation' do
+ let(:haml) { '%tag Hello #{"Tanuki"}!' } # rubocop:disable Lint/InterpolationCheck
+
+ it { is_expected.to report_lint }
+ end
+
+ context 'does not report when a tag has an inline script' do
+ let(:haml) { '%tag= "Hello Tanuki"' }
+
+ it { is_expected.not_to report_lint }
+ end
+
+ context 'does not report when a tag is empty' do
+ let(:haml) { '%tag' }
+
+ it { is_expected.not_to report_lint }
+ end
+
+ context 'reports multiple when a tag has multiline plain nodes split by non-text nodes' do
+ let(:haml) { <<-HAML }
+ %tag
+ Hello
+ .split-node There
+ Tanuki
+ HAML
+
+ it { is_expected.to report_lint count: 3 }
+ end
+end