|
1 | 1 | require 'spec_helper' |
| 2 | +# rubocop:disable Lint/RedundantRequireStatement |
| 3 | +require 'pp' |
| 4 | +# rubocop:enable Lint/RedundantRequireStatement |
2 | 5 |
|
3 | 6 | describe 'strict_indent' do |
4 | 7 | before do |
@@ -90,4 +93,74 @@ class () {} |
90 | 93 | expect(problems).to have(0).problems |
91 | 94 | end |
92 | 95 | end |
| 96 | + |
| 97 | + context 'misplaced resource semicolons' do |
| 98 | + before do |
| 99 | + PuppetLint.configuration.fix = true |
| 100 | + end |
| 101 | + |
| 102 | + after do |
| 103 | + PuppetLint.configuration.fix = false |
| 104 | + end |
| 105 | + |
| 106 | + let(:code) do |
| 107 | + <<~EOF |
| 108 | + file { |
| 109 | + default: |
| 110 | + ensure => file, |
| 111 | + owner => 'root', |
| 112 | + group => 'wheel', |
| 113 | + mode => '0600', |
| 114 | + ; |
| 115 | + ['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']: |
| 116 | + # use all defaults |
| 117 | + ; |
| 118 | + ['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']: |
| 119 | + # override mode |
| 120 | + mode => '0644', |
| 121 | + ; |
| 122 | + } |
| 123 | + EOF |
| 124 | + end |
| 125 | + |
| 126 | + let(:fixed) do |
| 127 | + <<~EOF |
| 128 | + file { |
| 129 | + default: |
| 130 | + ensure => file, |
| 131 | + owner => 'root', |
| 132 | + group => 'wheel', |
| 133 | + mode => '0600', |
| 134 | + ; |
| 135 | + ['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']: |
| 136 | + # use all defaults |
| 137 | + ; |
| 138 | + ['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']: |
| 139 | + # override mode |
| 140 | + mode => '0644', |
| 141 | + ; |
| 142 | + } |
| 143 | + EOF |
| 144 | + end |
| 145 | + |
| 146 | + it 'detects three problems' do |
| 147 | + expect(problems).to have(3).problem |
| 148 | + end |
| 149 | + |
| 150 | + it 'fixes the first problem' do |
| 151 | + expect(problems).to contain_fixed('indent should be 2 chars and is 4').on_line(7).in_column(1) |
| 152 | + end |
| 153 | + |
| 154 | + it 'fixes the second problem' do |
| 155 | + expect(problems).to contain_fixed('indent should be 2 chars and is 4').on_line(10).in_column(1) |
| 156 | + end |
| 157 | + |
| 158 | + it 'fixes the third problem' do |
| 159 | + expect(problems).to contain_fixed('indent should be 2 chars and is 0').on_line(14).in_column(1) |
| 160 | + end |
| 161 | + |
| 162 | + it 'moves the semicolons' do |
| 163 | + expect(manifest).to eq fixed |
| 164 | + end |
| 165 | + end |
93 | 166 | end |
0 commit comments