puppet-lint-manifest_whitespace-check 0.2.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,9 +3,11 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe 'manifest_whitespace_double_newline_end_of_file' do
6
+ let(:single_newline_end_of_file_msg) { 'there should be a single newline at the end of a manifest' }
7
+
6
8
  context 'with good example' do
7
9
  let(:code) do
8
- <<~EOF
10
+ <<~CODE
9
11
  class example (
10
12
 
11
13
 
@@ -14,51 +16,49 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
14
16
 
15
17
 
16
18
  }
17
- EOF
19
+ CODE
18
20
  end
19
21
 
20
- it 'should not detect any problems' do
22
+ it 'does not detect any problems' do
21
23
  expect(problems).to be_empty
22
24
  end
23
25
  end
24
26
 
25
- let(:single_newline_end_of_file_msg) { 'there should be a single newline at the end of a manifest' }
26
-
27
27
  context 'with fix disabled' do
28
28
  context 'with 1 empty line at the end of a manifest' do
29
29
  let(:code) do
30
- <<~EOF
30
+ <<~CODE
31
31
  class example {
32
32
  }
33
33
 
34
- EOF
34
+ CODE
35
35
  end
36
36
 
37
- it 'should detect a single problem' do
37
+ it 'detects a single problem' do
38
38
  expect(problems).to have(1).problem
39
39
  end
40
40
 
41
- it 'should create a error' do
41
+ it 'creates a error' do
42
42
  expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(3).in_column(1)
43
43
  end
44
44
  end
45
45
 
46
46
  context 'with 3 empty lines at the end of a manifest' do
47
47
  let(:code) do
48
- <<~EOF
48
+ <<~CODE
49
49
  class example {
50
50
  }
51
51
 
52
52
 
53
53
 
54
- EOF
54
+ CODE
55
55
  end
56
56
 
57
- it 'should detect 3 problems' do
57
+ it 'detects 3 problems' do
58
58
  expect(problems).to have(3).problem
59
59
  end
60
60
 
61
- it 'should create a error' do
61
+ it 'creates a error' do
62
62
  expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(3).in_column(1)
63
63
  expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(4).in_column(1)
64
64
  expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(5).in_column(1)
@@ -77,58 +77,58 @@ describe 'manifest_whitespace_double_newline_end_of_file' do
77
77
 
78
78
  context 'with 1 empty line at the end of a manifest' do
79
79
  let(:code) do
80
- <<~EOF
80
+ <<~CODE
81
81
  class example {
82
82
  }
83
83
 
84
- EOF
84
+ CODE
85
85
  end
86
86
 
87
- it 'should detect a single problem' do
87
+ it 'detects a single problem' do
88
88
  expect(problems).to have(1).problem
89
89
  end
90
90
 
91
- it 'should fix the manifest' do
91
+ it 'fixes the manifest' do
92
92
  expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(3).in_column(1)
93
93
  end
94
94
 
95
- it 'should add the final newline' do
95
+ it 'adds the final newline' do
96
96
  expect(manifest).to eq(
97
- <<~EOF
97
+ <<~CODE,
98
98
  class example {
99
99
  }
100
- EOF
100
+ CODE
101
101
  )
102
102
  end
103
103
  end
104
104
 
105
105
  context 'with 3 empty lines at the end of a manifest' do
106
106
  let(:code) do
107
- <<~EOF
107
+ <<~CODE
108
108
  class example {
109
109
  }
110
110
 
111
111
 
112
112
 
113
- EOF
113
+ CODE
114
114
  end
115
115
 
116
- it 'should detect 3 problems' do
116
+ it 'detects 3 problems' do
117
117
  expect(problems).to have(3).problem
118
118
  end
119
119
 
120
- it 'should fix the manifest' do
120
+ it 'fixes the manifest' do
121
121
  expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(3).in_column(1)
122
122
  expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(4).in_column(1)
123
123
  expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(5).in_column(1)
124
124
  end
125
125
 
126
- it 'should add the final newline' do
126
+ it 'adds the final newline' do
127
127
  expect(manifest).to eq(
128
- <<~EOF
128
+ <<~CODE,
129
129
  class example {
130
130
  }
131
- EOF
131
+ CODE
132
132
  )
133
133
  end
134
134
  end
@@ -7,22 +7,22 @@ describe 'manifest_whitespace_two_empty_lines' do
7
7
 
8
8
  context 'with two spaces' do
9
9
  let(:code) do
10
- <<~EOF
10
+ <<~CODE
11
11
  class { 'example2':
12
12
  param1 => 'value1',
13
13
 
14
14
 
15
15
  param2 => 'value2',
16
16
  }
17
- EOF
17
+ CODE
18
18
  end
19
19
 
20
20
  context 'with fix disabled' do
21
- it 'should detect a single problem' do
21
+ it 'detects a single problem' do
22
22
  expect(problems).to have(1).problem
23
23
  end
24
24
 
25
- it 'should create a error' do
25
+ it 'creates a error' do
26
26
  expect(problems).to contain_error(single_space_msg).on_line(4).in_column(1)
27
27
  end
28
28
  end
@@ -36,23 +36,23 @@ describe 'manifest_whitespace_two_empty_lines' do
36
36
  PuppetLint.configuration.fix = false
37
37
  end
38
38
 
39
- it 'should detect a single problem' do
39
+ it 'detects a single problem' do
40
40
  expect(problems).to have(1).problem
41
41
  end
42
42
 
43
- it 'should fix the manifest' do
43
+ it 'fixes the manifest' do
44
44
  expect(problems).to contain_fixed(single_space_msg)
45
45
  end
46
46
 
47
- it 'should fix the space' do
47
+ it 'fixes the space' do
48
48
  expect(manifest).to eq(
49
- <<~EOF,
49
+ <<~CODE,
50
50
  class { 'example2':
51
51
  param1 => 'value1',
52
52
 
53
53
  param2 => 'value2',
54
54
  }
55
- EOF
55
+ CODE
56
56
  )
57
57
  end
58
58
  end
@@ -11,11 +11,11 @@ describe 'manifest_whitespace_missing_newline_end_of_file' do
11
11
  'class example { }'
12
12
  end
13
13
 
14
- it 'should detect a single problem' do
14
+ it 'detects a single problem' do
15
15
  expect(problems).to have(1).problem
16
16
  end
17
17
 
18
- it 'should create a error' do
18
+ it 'creates a error' do
19
19
  expect(problems).to contain_error(single_newline_end_of_file_msg).on_line(1).in_column(17)
20
20
  end
21
21
  end
@@ -35,17 +35,32 @@ describe 'manifest_whitespace_missing_newline_end_of_file' do
35
35
  'class example { }'
36
36
  end
37
37
 
38
- it 'should detect a single problem' do
38
+ it 'detects a single problem' do
39
39
  expect(problems).to have(1).problem
40
40
  end
41
41
 
42
- it 'should fix the manifest' do
42
+ it 'fixes the manifest' do
43
43
  expect(problems).to contain_fixed(single_newline_end_of_file_msg).on_line(1).in_column(17)
44
44
  end
45
45
 
46
- it 'should add the final newline' do
46
+ it 'adds the final newline' do
47
47
  expect(manifest).to eq("class example { }\n")
48
48
  end
49
49
  end
50
+
51
+ context 'inside heredoc' do
52
+ let(:code) do
53
+ <<~CODE
54
+ $value = @("END_OF_HD")
55
+ SomeData
56
+ | - END_OF_HD
57
+ $other_value = 5
58
+ CODE
59
+ end
60
+
61
+ it 'detects no problems' do
62
+ expect(problems).to be_empty
63
+ end
64
+ end
50
65
  end
51
66
  end
@@ -7,7 +7,7 @@ describe 'manifest_whitespace_newline_beginning_of_file' do
7
7
 
8
8
  context 'with good example' do
9
9
  let(:code) do
10
- <<~EOF
10
+ <<~CODE
11
11
  class example (
12
12
 
13
13
 
@@ -16,10 +16,10 @@ describe 'manifest_whitespace_newline_beginning_of_file' do
16
16
 
17
17
 
18
18
  }
19
- EOF
19
+ CODE
20
20
  end
21
21
 
22
- it 'should not detect any problems' do
22
+ it 'does not detect any problems' do
23
23
  expect(problems).to be_empty
24
24
  end
25
25
  end
@@ -27,38 +27,38 @@ describe 'manifest_whitespace_newline_beginning_of_file' do
27
27
  context 'with fix disabled' do
28
28
  context 'with 1 empty line at the beginning of a manifest' do
29
29
  let(:code) do
30
- <<~EOF
30
+ <<~CODE
31
31
 
32
32
  class example {
33
33
  }
34
- EOF
34
+ CODE
35
35
  end
36
36
 
37
- it 'should detect a single problem' do
37
+ it 'detects a single problem' do
38
38
  expect(problems).to have(1).problem
39
39
  end
40
40
 
41
- it 'should create a error' do
41
+ it 'creates a error' do
42
42
  expect(problems).to contain_error(single_beginning_of_file_msg).on_line(1).in_column(1)
43
43
  end
44
44
  end
45
45
 
46
46
  context 'with 3 empty lines at the beginning of a manifest' do
47
47
  let(:code) do
48
- <<~EOF
48
+ <<~CODE
49
49
 
50
50
 
51
51
 
52
52
  class example {
53
53
  }
54
- EOF
54
+ CODE
55
55
  end
56
56
 
57
- it 'should detect 3 problems' do
57
+ it 'detects 3 problems' do
58
58
  expect(problems).to have(3).problem
59
59
  end
60
60
 
61
- it 'should create a error' do
61
+ it 'creates a error' do
62
62
  expect(problems).to contain_error(single_beginning_of_file_msg).on_line(1).in_column(1)
63
63
  expect(problems).to contain_error(single_beginning_of_file_msg).on_line(2).in_column(1)
64
64
  expect(problems).to contain_error(single_beginning_of_file_msg).on_line(3).in_column(1)
@@ -77,58 +77,58 @@ describe 'manifest_whitespace_newline_beginning_of_file' do
77
77
 
78
78
  context 'with 1 empty line at the beginning of a manifest' do
79
79
  let(:code) do
80
- <<~EOF
80
+ <<~CODE
81
81
 
82
82
  class example {
83
83
  }
84
- EOF
84
+ CODE
85
85
  end
86
86
 
87
- it 'should detect a single problem' do
87
+ it 'detects a single problem' do
88
88
  expect(problems).to have(1).problem
89
89
  end
90
90
 
91
- it 'should fix the manifest' do
91
+ it 'fixes the manifest' do
92
92
  expect(problems).to contain_fixed(single_beginning_of_file_msg).on_line(1).in_column(1)
93
93
  end
94
94
 
95
- it 'should add the final newline' do
95
+ it 'adds the final newline' do
96
96
  expect(manifest).to eq(
97
- <<~EOF,
97
+ <<~CODE,
98
98
  class example {
99
99
  }
100
- EOF
100
+ CODE
101
101
  )
102
102
  end
103
103
  end
104
104
 
105
105
  context 'with 3 empty lines at the beginning of a manifest' do
106
106
  let(:code) do
107
- <<~EOF
107
+ <<~CODE
108
108
 
109
109
 
110
110
 
111
111
  class example {
112
112
  }
113
- EOF
113
+ CODE
114
114
  end
115
115
 
116
- it 'should detect 3 problem' do
116
+ it 'detects 3 problem' do
117
117
  expect(problems).to have(3).problem
118
118
  end
119
119
 
120
- it 'should fix the manifest' do
120
+ it 'fixes the manifest' do
121
121
  expect(problems).to contain_fixed(single_beginning_of_file_msg).on_line(1).in_column(1)
122
122
  expect(problems).to contain_fixed(single_beginning_of_file_msg).on_line(2).in_column(1)
123
123
  expect(problems).to contain_fixed(single_beginning_of_file_msg).on_line(3).in_column(1)
124
124
  end
125
125
 
126
- it 'should add the final newline' do
126
+ it 'adds the final newline' do
127
127
  expect(manifest).to eq(
128
- <<~EOF,
128
+ <<~CODE,
129
129
  class example {
130
130
  }
131
- EOF
131
+ CODE
132
132
  )
133
133
  end
134
134
  end