puppet-lint-manifest_whitespace-check 0.2.8 → 0.2.9

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.
@@ -5,76 +5,88 @@ require 'spec_helper'
5
5
  describe 'manifest_whitespace_opening_brace_before' do
6
6
  let(:opening_brace_msg) { 'there should be a single space before an opening brace' }
7
7
 
8
+ context 'parameters without space' do
9
+ let(:code) do
10
+ <<~CODE
11
+ $foo = lookup('foo::bar',Hash,'first',{})
12
+ CODE
13
+ end
14
+
15
+ it 'detects a problem' do
16
+ expect(problems).not_to be_empty
17
+ end
18
+ end
19
+
8
20
  context 'with comment only' do
9
21
  let(:code) do
10
- <<~EOF
22
+ <<~CODE
11
23
  $value7 = {
12
24
  # nothing
13
25
  }
14
- EOF
26
+ CODE
15
27
  end
16
28
 
17
- it 'should detect no problems' do
29
+ it 'detects no problems' do
18
30
  expect(problems).to be_empty
19
31
  end
20
32
  end
21
33
 
22
34
  context 'inside, inline with function' do
23
35
  let(:code) do
24
- <<~EOF
36
+ <<~CODE
25
37
  $sssd_config = {
26
38
  ▏ 'sssd' => merge($config, {
27
39
  ▏ ▏ ▏ 'domains' => $domains,
28
40
  ▏ ▏ ▏ 'services' => 'nss,pam',
29
41
  ▏ }),
30
42
  }
31
- EOF
43
+ CODE
32
44
  end
33
45
 
34
- it 'should detect no problems' do
46
+ it 'detects no problems' do
35
47
  expect(problems).to be_empty
36
48
  end
37
49
  end
38
50
 
39
51
  context 'inside interpolation' do
40
52
  let(:code) do
41
- <<~EOF
53
+ <<~CODE
42
54
  my_define { "foo-${myvar}": }
43
- EOF
55
+ CODE
44
56
  end
45
57
 
46
- it 'should detect no problems' do
58
+ it 'detects no problems' do
47
59
  expect(problems).to be_empty
48
60
  end
49
61
  end
50
62
 
51
63
  context 'inline with a function before' do
52
64
  let(:code) do
53
- <<~EOF
65
+ <<~CODE
54
66
  Hash( { $key => $return_value })
55
- EOF
67
+ CODE
56
68
  end
57
69
 
58
- it 'should detect 1 problem' do
70
+ it 'detects 1 problem' do
59
71
  expect(problems).to have(1).problem
60
72
  end
61
73
  end
62
74
 
63
75
  context 'inline with a function' do
64
76
  let(:code) do
65
- <<~EOF
77
+ <<~CODE
66
78
  Hash({ $key => $return_value })
67
- EOF
79
+ CODE
68
80
  end
69
81
 
70
- it 'should detect no problems' do
82
+ it 'detects no problems' do
71
83
  expect(problems).to be_empty
72
84
  end
73
85
  end
74
86
 
75
87
  context 'inside a function' do
76
88
  let(:code) do
77
- <<~EOF
89
+ <<~CODE
78
90
  $my_var = lookup(
79
91
  {
80
92
  'name' => 'my_module::my_var',
@@ -83,44 +95,44 @@ describe 'manifest_whitespace_opening_brace_before' do
83
95
  'default_value' => [],
84
96
  }
85
97
  )
86
- EOF
98
+ CODE
87
99
  end
88
100
 
89
- it 'should detect no problems' do
101
+ it 'detects no problems' do
90
102
  expect(problems).to be_empty
91
103
  end
92
104
  end
93
105
 
94
106
  context 'with cases' do
95
107
  let(:code) do
96
- <<~EOF
108
+ <<~CODE
97
109
  case $facts['kernel'] {
98
110
  'OpenBSD': { $has_wordexp = false }
99
111
  default: { $has_wordexp = true }
100
112
  }
101
- EOF
113
+ CODE
102
114
  end
103
115
 
104
- it 'should detect no problems' do
116
+ it 'detects no problems' do
105
117
  expect(problems).to be_empty
106
118
  end
107
119
  end
108
120
 
109
121
  context 'with class no spaces' do
110
122
  let(:code) do
111
- <<~EOF
123
+ <<~CODE
112
124
  class example{
113
125
  # some generic comment
114
126
  }
115
- EOF
127
+ CODE
116
128
  end
117
129
 
118
130
  context 'with fix disabled' do
119
- it 'should detect a problem' do
131
+ it 'detects a problem' do
120
132
  expect(problems).to have(1).problem
121
133
  end
122
134
 
123
- it 'should create a error' do
135
+ it 'creates a error' do
124
136
  expect(problems).to contain_error(opening_brace_msg).on_line(1).in_column(14)
125
137
  end
126
138
  end
@@ -134,13 +146,13 @@ describe 'manifest_whitespace_opening_brace_before' do
134
146
  PuppetLint.configuration.fix = false
135
147
  end
136
148
 
137
- it 'should add a space' do
149
+ it 'adds a space' do
138
150
  expect(manifest).to eq(
139
- <<~EOF,
151
+ <<~CODE,
140
152
  class example {
141
153
  # some generic comment
142
154
  }
143
- EOF
155
+ CODE
144
156
  )
145
157
  end
146
158
  end
@@ -148,7 +160,7 @@ describe 'manifest_whitespace_opening_brace_before' do
148
160
 
149
161
  context 'with no spaces' do
150
162
  let(:code) do
151
- <<~EOF
163
+ <<~CODE
152
164
  # example
153
165
  #
154
166
  # Main class, includes all other classes.
@@ -181,15 +193,15 @@ describe 'manifest_whitespace_opening_brace_before' do
181
193
  }
182
194
  }
183
195
  }
184
- EOF
196
+ CODE
185
197
  end
186
198
 
187
199
  context 'with fix disabled' do
188
- it 'should detect three problems' do
200
+ it 'detects three problems' do
189
201
  expect(problems).to have(3).problem
190
202
  end
191
203
 
192
- it 'should create a error' do
204
+ it 'creates a error' do
193
205
  expect(problems).to contain_error(opening_brace_msg).on_line(8).in_column(2)
194
206
  end
195
207
  end
@@ -203,17 +215,17 @@ describe 'manifest_whitespace_opening_brace_before' do
203
215
  PuppetLint.configuration.fix = false
204
216
  end
205
217
 
206
- it 'should detect three problems' do
218
+ it 'detects three problems' do
207
219
  expect(problems).to have(3).problem
208
220
  end
209
221
 
210
- it 'should create a error' do
222
+ it 'creates a error' do
211
223
  expect(problems).to contain_fixed(opening_brace_msg)
212
224
  end
213
225
 
214
- it 'should add spaces' do
226
+ it 'adds spaces' do
215
227
  expect(manifest).to eq(
216
- <<~EOF,
228
+ <<~CODE,
217
229
  # example
218
230
  #
219
231
  # Main class, includes all other classes.
@@ -246,7 +258,7 @@ describe 'manifest_whitespace_opening_brace_before' do
246
258
  }
247
259
  }
248
260
  }
249
- EOF
261
+ CODE
250
262
  )
251
263
  end
252
264
  end
@@ -254,7 +266,7 @@ describe 'manifest_whitespace_opening_brace_before' do
254
266
 
255
267
  context 'with two spaces' do
256
268
  let(:code) do
257
- <<~EOF
269
+ <<~CODE
258
270
  # example
259
271
  #
260
272
  # Main class, includes all other classes.
@@ -281,15 +293,15 @@ describe 'manifest_whitespace_opening_brace_before' do
281
293
  }
282
294
  }
283
295
  }
284
- EOF
296
+ CODE
285
297
  end
286
298
 
287
299
  context 'with fix disabled' do
288
- it 'should detect a single problem' do
300
+ it 'detects a single problem' do
289
301
  expect(problems).to have(3).problem
290
302
  end
291
303
 
292
- it 'should create a error' do
304
+ it 'creates a error' do
293
305
  expect(problems).to contain_error(opening_brace_msg).on_line(8).in_column(4)
294
306
  end
295
307
  end
@@ -303,17 +315,17 @@ describe 'manifest_whitespace_opening_brace_before' do
303
315
  PuppetLint.configuration.fix = false
304
316
  end
305
317
 
306
- it 'should detect a single problem' do
318
+ it 'detects a single problem' do
307
319
  expect(problems).to have(3).problem
308
320
  end
309
321
 
310
- it 'should create a error' do
322
+ it 'creates a error' do
311
323
  expect(problems).to contain_fixed(opening_brace_msg)
312
324
  end
313
325
 
314
- it 'should remove a space' do
326
+ it 'removes a space' do
315
327
  expect(manifest).to eq(
316
- <<~EOF,
328
+ <<~CODE,
317
329
  # example
318
330
  #
319
331
  # Main class, includes all other classes.
@@ -340,7 +352,7 @@ describe 'manifest_whitespace_opening_brace_before' do
340
352
  }
341
353
  }
342
354
  }
343
- EOF
355
+ CODE
344
356
  )
345
357
  end
346
358
  end
@@ -348,7 +360,7 @@ describe 'manifest_whitespace_opening_brace_before' do
348
360
 
349
361
  context 'with newline' do
350
362
  let(:code) do
351
- <<~EOF
363
+ <<~CODE
352
364
  # example
353
365
  #
354
366
  # Main class, includes all other classes.
@@ -378,15 +390,15 @@ describe 'manifest_whitespace_opening_brace_before' do
378
390
  }
379
391
  }
380
392
  }
381
- EOF
393
+ CODE
382
394
  end
383
395
 
384
396
  context 'with fix disabled' do
385
- it 'should detect a single problem' do
397
+ it 'detects a single problem' do
386
398
  expect(problems).to have(3).problem
387
399
  end
388
400
 
389
- it 'should create a error' do
401
+ it 'creates a error' do
390
402
  expect(problems).to contain_error(opening_brace_msg).on_line(9).in_column(1)
391
403
  end
392
404
  end
@@ -400,17 +412,17 @@ describe 'manifest_whitespace_opening_brace_before' do
400
412
  PuppetLint.configuration.fix = false
401
413
  end
402
414
 
403
- it 'should detect a single problem' do
415
+ it 'detects a single problem' do
404
416
  expect(problems).to have(3).problem
405
417
  end
406
418
 
407
- it 'should create a error' do
419
+ it 'creates a error' do
408
420
  expect(problems).to contain_fixed(opening_brace_msg)
409
421
  end
410
422
 
411
- it 'should fix the newline' do
423
+ it 'fixes the newline' do
412
424
  expect(manifest).to eq(
413
- <<~EOF,
425
+ <<~CODE,
414
426
  # example
415
427
  #
416
428
  # Main class, includes all other classes.
@@ -437,7 +449,7 @@ describe 'manifest_whitespace_opening_brace_before' do
437
449
  }
438
450
  }
439
451
  }
440
- EOF
452
+ CODE
441
453
  )
442
454
  end
443
455
  end
@@ -445,7 +457,7 @@ describe 'manifest_whitespace_opening_brace_before' do
445
457
 
446
458
  context 'with comment' do
447
459
  let(:code) do
448
- <<~EOF
460
+ <<~CODE
449
461
  # example
450
462
  #
451
463
  # Main class, includes all other classes.
@@ -474,11 +486,11 @@ describe 'manifest_whitespace_opening_brace_before' do
474
486
  }
475
487
  }
476
488
  }
477
- EOF
489
+ CODE
478
490
  end
479
491
 
480
492
  context 'with fix disabled' do
481
- it 'should detect a single problem' do
493
+ it 'detects a single problem' do
482
494
  expect(problems).to be_empty
483
495
  end
484
496
  end
@@ -486,7 +498,7 @@ describe 'manifest_whitespace_opening_brace_before' do
486
498
 
487
499
  context 'with good inherits' do
488
500
  let(:code) do
489
- <<~EOF
501
+ <<~CODE
490
502
  # example
491
503
  #
492
504
  # Main class, includes all other classes.
@@ -513,11 +525,11 @@ describe 'manifest_whitespace_opening_brace_before' do
513
525
  }
514
526
  }
515
527
  }
516
- EOF
528
+ CODE
517
529
  end
518
530
 
519
531
  context 'with fix disabled' do
520
- it 'should detect no problem' do
532
+ it 'detects no problem' do
521
533
  expect(problems).to be_empty
522
534
  end
523
535
  end
@@ -525,7 +537,7 @@ describe 'manifest_whitespace_opening_brace_before' do
525
537
 
526
538
  context 'with bad inherits' do
527
539
  let(:code) do
528
- <<~EOF
540
+ <<~CODE
529
541
  # example
530
542
  #
531
543
  # Main class, includes all other classes.
@@ -552,15 +564,15 @@ describe 'manifest_whitespace_opening_brace_before' do
552
564
  }
553
565
  }
554
566
  }
555
- EOF
567
+ CODE
556
568
  end
557
569
 
558
570
  context 'with fix disabled' do
559
- it 'should detect a single problem' do
571
+ it 'detects a single problem' do
560
572
  expect(problems).to have(1).problem
561
573
  end
562
574
 
563
- it 'should create a error' do
575
+ it 'creates a error' do
564
576
  expect(problems).to contain_error(opening_brace_msg).on_line(8).in_column(22)
565
577
  end
566
578
  end
@@ -574,13 +586,13 @@ describe 'manifest_whitespace_opening_brace_before' do
574
586
  PuppetLint.configuration.fix = false
575
587
  end
576
588
 
577
- it 'should detect a missing space' do
589
+ it 'detects a missing space' do
578
590
  expect(problems).to have(1).problem
579
591
  end
580
592
 
581
- it 'should add the space' do
593
+ it 'adds the space' do
582
594
  expect(manifest).to eq(
583
- <<~EOF,
595
+ <<~CODE,
584
596
  # example
585
597
  #
586
598
  # Main class, includes all other classes.
@@ -607,7 +619,7 @@ describe 'manifest_whitespace_opening_brace_before' do
607
619
  }
608
620
  }
609
621
  }
610
- EOF
622
+ CODE
611
623
  )
612
624
  end
613
625
  end
@@ -619,7 +631,7 @@ describe 'manifest_whitespace_opening_brace_after' do
619
631
 
620
632
  context 'with two spaces' do
621
633
  let(:code) do
622
- <<~EOF
634
+ <<~CODE
623
635
  # example
624
636
  #
625
637
  # Main class, includes all other classes.
@@ -652,15 +664,15 @@ describe 'manifest_whitespace_opening_brace_after' do
652
664
  }
653
665
  }
654
666
  }
655
- EOF
667
+ CODE
656
668
  end
657
669
 
658
670
  context 'with fix disabled' do
659
- it 'should detect 2 problems' do
671
+ it 'detects 2 problems' do
660
672
  expect(problems).to have(2).problem
661
673
  end
662
674
 
663
- it 'should create a error' do
675
+ it 'creates a error' do
664
676
  expect(problems).to contain_error(opening_brace_msg).on_line(9).in_column(14)
665
677
  end
666
678
  end
@@ -674,17 +686,17 @@ describe 'manifest_whitespace_opening_brace_after' do
674
686
  PuppetLint.configuration.fix = false
675
687
  end
676
688
 
677
- it 'should detect 2 problems' do
689
+ it 'detects 2 problems' do
678
690
  expect(problems).to have(2).problem
679
691
  end
680
692
 
681
- it 'should create a error' do
693
+ it 'creates a error' do
682
694
  expect(problems).to contain_fixed(opening_brace_msg)
683
695
  end
684
696
 
685
- it 'should add spaces' do
697
+ it 'adds spaces' do
686
698
  expect(manifest).to eq(
687
- <<~EOF,
699
+ <<~CODE,
688
700
  # example
689
701
  #
690
702
  # Main class, includes all other classes.
@@ -717,7 +729,7 @@ describe 'manifest_whitespace_opening_brace_after' do
717
729
  }
718
730
  }
719
731
  }
720
- EOF
732
+ CODE
721
733
  )
722
734
  end
723
735
  end
@@ -725,7 +737,7 @@ describe 'manifest_whitespace_opening_brace_after' do
725
737
 
726
738
  context 'with no spaces' do
727
739
  let(:code) do
728
- <<~EOF
740
+ <<~CODE
729
741
  # example
730
742
  #
731
743
  # Main class, includes all other classes.
@@ -752,15 +764,15 @@ describe 'manifest_whitespace_opening_brace_after' do
752
764
  }
753
765
  }
754
766
  }
755
- EOF
767
+ CODE
756
768
  end
757
769
 
758
770
  context 'with fix disabled' do
759
- it 'should detect 2 problems' do
771
+ it 'detects 2 problems' do
760
772
  expect(problems).to have(2).problem
761
773
  end
762
774
 
763
- it 'should create a error' do
775
+ it 'creates a error' do
764
776
  expect(problems).to contain_error(opening_brace_msg).on_line(9).in_column(14)
765
777
  end
766
778
  end
@@ -774,17 +786,17 @@ describe 'manifest_whitespace_opening_brace_after' do
774
786
  PuppetLint.configuration.fix = false
775
787
  end
776
788
 
777
- it 'should detect 2 problems' do
789
+ it 'detects 2 problems' do
778
790
  expect(problems).to have(2).problem
779
791
  end
780
792
 
781
- it 'should create a error' do
793
+ it 'creates a error' do
782
794
  expect(problems).to contain_fixed(opening_brace_msg)
783
795
  end
784
796
 
785
- it 'should add spaces' do
797
+ it 'adds spaces' do
786
798
  expect(manifest).to eq(
787
- <<~EOF,
799
+ <<~CODE,
788
800
  # example
789
801
  #
790
802
  # Main class, includes all other classes.
@@ -811,7 +823,7 @@ describe 'manifest_whitespace_opening_brace_after' do
811
823
  }
812
824
  }
813
825
  }
814
- EOF
826
+ CODE
815
827
  )
816
828
  end
817
829
  end
@@ -819,7 +831,7 @@ describe 'manifest_whitespace_opening_brace_after' do
819
831
 
820
832
  context 'with two newlines' do
821
833
  let(:code) do
822
- <<~EOF
834
+ <<~CODE
823
835
  # example
824
836
  #
825
837
  # Main class, includes all other classes.
@@ -851,15 +863,15 @@ describe 'manifest_whitespace_opening_brace_after' do
851
863
  }
852
864
  }
853
865
  }
854
- EOF
866
+ CODE
855
867
  end
856
868
 
857
869
  context 'with fix disabled' do
858
- it 'should detect 4 problems' do
870
+ it 'detects 4 problems' do
859
871
  expect(problems).to have(4).problem
860
872
  end
861
873
 
862
- it 'should create a error' do
874
+ it 'creates a error' do
863
875
  expect(problems).to contain_error(opening_brace_msg).on_line(9).in_column(1)
864
876
  end
865
877
  end
@@ -873,17 +885,17 @@ describe 'manifest_whitespace_opening_brace_after' do
873
885
  PuppetLint.configuration.fix = false
874
886
  end
875
887
 
876
- it 'should detect 4 problems' do
888
+ it 'detects 4 problems' do
877
889
  expect(problems).to have(4).problem
878
890
  end
879
891
 
880
- it 'should create a error' do
892
+ it 'creates a error' do
881
893
  expect(problems).to contain_fixed(opening_brace_msg)
882
894
  end
883
895
 
884
- it 'should add spaces' do
896
+ it 'adds spaces' do
885
897
  expect(manifest).to eq(
886
- <<~EOF,
898
+ <<~CODE,
887
899
  # example
888
900
  #
889
901
  # Main class, includes all other classes.
@@ -911,7 +923,7 @@ describe 'manifest_whitespace_opening_brace_after' do
911
923
  }
912
924
  }
913
925
  }
914
- EOF
926
+ CODE
915
927
  )
916
928
  end
917
929
  end