-
Notifications
You must be signed in to change notification settings - Fork 103
/
class_attribute_with_static_value_spec.rb
88 lines (61 loc) · 2.17 KB
/
class_attribute_with_static_value_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# frozen_string_literal: true
describe HamlLint::Linter::ClassAttributeWithStaticValue do
include_context 'linter'
context 'when tag contains no class attribute' do
let(:haml) { '%tag' }
it { should_not report_lint }
end
context 'when tag contains static class attribute' do
let(:haml) { '%tag.class' }
it { should_not report_lint }
end
context 'when implicit div contains static class attribute' do
let(:haml) { '.class' }
it { should_not report_lint }
end
context 'when tag contains dynamic class attribute' do
let(:haml) { '%tag{ class: status }' }
it { should_not report_lint }
end
context 'when tag contains dynamic class attribute with symbol value' do
let(:haml) { '%tag{ class: :status }' }
it { should report_lint }
end
context 'when tag contains dynamic class attribute with string value' do
let(:haml) { "%tag{ class: 'status' }" }
it { should report_lint }
end
context 'when tag contains dynamic class attribute with method call value' do
let(:haml) { '%th{ class: some_method_call }' }
it { should_not report_lint }
end
context 'when tag contains dynamic class attribute with ivar value' do
let(:haml) { '%th{ class: @some_ivar }' }
it { should_not report_lint }
end
context 'when tag contains attributes assigned via method call' do
let(:haml) { '%tag{ some_method_call }' }
it { should_not report_lint }
end
context 'when tag attributes contain syntax errors' do
let(:haml) { '%th{ :class: value }' }
it { should_not report_lint }
end
context 'when tag attributes contain invalid value' do
let(:haml) { "%th{ class: '{{value}}' }" }
it { should_not report_lint }
end
context 'when tag attributes are malformed' do
let(:haml) { %(%input{{type: "radio"}, "a" == "b" ? { checked: "checked" } : {}}) }
it { should_not report_lint }
end
context 'when tag has both HTML-style and hash-style attributes' do
let(:haml) { <<-HAML }
- MyStruct = Struct.new(:href)
- @title = 'Hello'
- @link = MyStruct.new('blahblah')
%a(title=@title){:href => @link.href} Stuff
HAML
it { should_not report_lint }
end
end