Skip to content

Commit ea3fe9d

Browse files
committed
reverting other test files
1 parent ba86611 commit ea3fe9d

File tree

2 files changed

+58
-56
lines changed

2 files changed

+58
-56
lines changed

.rubocop_todo.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-06-05 11:34:36 UTC using RuboCop version 1.70.0.
3+
# on 2025-06-05 11:55:03 UTC using RuboCop version 1.70.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -139,24 +139,26 @@ RSpec/BeNil:
139139
RSpec/DescribeClass:
140140
Enabled: false
141141

142-
# Offense count: 16
142+
# Offense count: 22
143143
# This cop supports safe autocorrection (--autocorrect).
144144
# Configuration parameters: AllowConsecutiveOneLiners.
145145
RSpec/EmptyLineAfterExample:
146146
Exclude:
147+
- 'spec/acceptance/composite_namevar_spec.rb'
147148
- 'spec/puppet/resource_api_spec.rb'
148149

149150
# Offense count: 37
150151
# Configuration parameters: CountAsOne.
151152
RSpec/ExampleLength:
152153
Max: 16
153154

154-
# Offense count: 45
155+
# Offense count: 46
155156
# This cop supports safe autocorrection (--autocorrect).
156157
# Configuration parameters: EnforcedStyle.
157158
# SupportedStyles: implicit, each, example
158159
RSpec/HookArgument:
159160
Exclude:
161+
- 'spec/acceptance/composite_namevar_spec.rb'
160162
- 'spec/puppet/resource_api_spec.rb'
161163

162164
# Offense count: 1
@@ -278,13 +280,20 @@ Style/RedundantAssignment:
278280
- 'lib/puppet/resource_api.rb'
279281
- 'spec/puppet/resource_api_spec.rb'
280282

281-
# Offense count: 39
283+
# Offense count: 32
284+
# This cop supports safe autocorrection (--autocorrect).
285+
Style/RedundantRegexpEscape:
286+
Exclude:
287+
- 'spec/acceptance/composite_namevar_spec.rb'
288+
289+
# Offense count: 78
282290
# This cop supports safe autocorrection (--autocorrect).
283291
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
284292
# SupportedStyles: slashes, percent_r, mixed
285293
Style/RegexpLiteral:
286294
Exclude:
287295
- 'lib/puppet/resource_api.rb'
296+
- 'spec/acceptance/composite_namevar_spec.rb'
288297
- 'spec/puppet/resource_api_spec.rb'
289298

290299
# Offense count: 1
@@ -300,12 +309,13 @@ Style/SoleNestedConditional:
300309
Exclude:
301310
- 'lib/puppet/resource_api.rb'
302311

303-
# Offense count: 2
312+
# Offense count: 3
304313
# This cop supports unsafe autocorrection (--autocorrect-all).
305314
# Configuration parameters: Mode.
306315
Style/StringConcatenation:
307316
Exclude:
308317
- 'lib/puppet/resource_api.rb'
318+
- 'spec/acceptance/composite_namevar_spec.rb'
309319

310320
# Offense count: 1
311321
# This cop supports safe autocorrection (--autocorrect).

spec/acceptance/composite_namevar_spec.rb

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -10,73 +10,65 @@
1010
describe 'using `puppet resource`' do
1111
it 'is returns the values correctly' do
1212
stdout_str, status = Open3.capture2e("puppet resource #{common_args} composite_namevar")
13-
expect(stdout_str.strip).to match(/^composite_namevar/)
14-
expect(stdout_str.strip).to match(/Looking for nil/)
13+
expect(stdout_str.strip).to match %r{^composite_namevar}
14+
expect(stdout_str.strip).to match %r{Looking for \[\]}
1515
expect(status).to eq 0
1616
end
17-
1817
it 'returns the required resource correctly' do
1918
stdout_str, status = Open3.capture2e("puppet resource #{common_args} composite_namevar php-yum")
20-
expect(stdout_str.strip).to match(/^composite_namevar \{ 'php-yum'/)
21-
expect(stdout_str.strip).to match(/ensure\s*=> 'present'/)
22-
expect(stdout_str.strip).to match(/package\s*=> 'php'/)
23-
expect(stdout_str.strip).to match(/manager\s*=> 'yum'/)
24-
expect(stdout_str.strip).to match(/Looking for nil/)
19+
expect(stdout_str.strip).to match %r{^composite_namevar \{ \'php-yum\'}
20+
expect(stdout_str.strip).to match %r{ensure\s*=> \'present\'}
21+
expect(stdout_str.strip).to match %r{package\s*=> \'php\'}
22+
expect(stdout_str.strip).to match %r{manager\s*=> \'yum\'}
23+
expect(stdout_str.strip).to match %r{Looking for \[\]}
2524
expect(status.exitstatus).to eq 0
2625
end
27-
2826
it 'throws error if title is not a matching title_pattern' do
2927
stdout_str, status = Open3.capture2e("puppet resource #{common_args} composite_namevar php123 package=php manager=yum")
30-
expect(stdout_str.strip).to match(/No set of title patterns matched the title "php123"/)
31-
expect(stdout_str.strip).not_to match(/Looking for/)
28+
expect(stdout_str.strip).to match %r{No set of title patterns matched the title "php123"}
29+
expect(stdout_str.strip).not_to match %r{Looking for}
3230
expect(status.exitstatus).to eq 1
3331
end
34-
3532
it 'returns the match if alternative title_pattern matches' do
3633
stdout_str, status = Open3.capture2e("puppet resource #{common_args} composite_namevar php/gem")
37-
expect(stdout_str.strip).to match %r{^composite_namevar \{ 'php/gem'}
38-
expect(stdout_str.strip).to match(/ensure\s*=> 'present'/)
39-
# "Looking for" will return nil as puppet resource will have already fetched
40-
# the resource in instances():
41-
expect(stdout_str.strip).to match(/Looking for nil/)
34+
expect(stdout_str.strip).to match %r{^composite_namevar \{ \'php/gem\'}
35+
expect(stdout_str.strip).to match %r{ensure\s*=> \'present\'}
36+
expect(stdout_str.strip).to match %r{Looking for \[\{:package=>"php", :manager=>"gem"\}\]}
4237
expect(status.exitstatus).to eq 0
4338
end
44-
4539
it 'properly identifies an absent resource if only the title is provided' do
4640
stdout_str, status = Open3.capture2e("puppet resource #{common_args} composite_namevar php-wibble")
47-
expect(stdout_str.strip).to match(/^composite_namevar \{ 'php-wibble'/)
48-
expect(stdout_str.strip).to match(/ensure\s*=> 'absent'/)
49-
expect(stdout_str.strip).to match(/Looking for \[\{:package=>"php", :manager=>"wibble"\}\]/)
41+
expect(stdout_str.strip).to match %r{^composite_namevar \{ \'php-wibble\'}
42+
expect(stdout_str.strip).to match %r{ensure\s*=> \'absent\'}
43+
expect(stdout_str.strip).to match %r{Looking for \[\{:package=>"php", :manager=>"wibble"\}\]}
5044
expect(status.exitstatus).to eq 0
5145
end
52-
5346
it 'creates a previously absent resource' do
5447
stdout_str, status = Open3.capture2e("puppet resource #{common_args} composite_namevar php-wibble ensure='present'")
55-
expect(stdout_str.strip).to match(/^composite_namevar \{ 'php-wibble'/)
56-
expect(stdout_str.strip).to match(/ensure\s*=> 'present'/)
57-
expect(stdout_str.strip).to match(/package\s*=> 'php'/)
58-
expect(stdout_str.strip).to match(/manager\s*=> 'wibble'/)
59-
expect(stdout_str.strip).to match(/Looking for \[\{:package=>"php", :manager=>"wibble"\}\]/)
48+
expect(stdout_str.strip).to match %r{^composite_namevar \{ \'php-wibble\'}
49+
expect(stdout_str.strip).to match %r{ensure\s*=> \'present\'}
50+
expect(stdout_str.strip).to match %r{package\s*=> \'php\'}
51+
expect(stdout_str.strip).to match %r{manager\s*=> \'wibble\'}
52+
expect(stdout_str.strip).to match %r{Looking for \[\{:package=>"php", :manager=>"wibble"\}\]}
6053
expect(status.exitstatus).to eq 0
6154
end
62-
63-
it 'removes an existing resource' do
55+
it 'will remove an existing resource' do
6456
stdout_str, status = Open3.capture2e("puppet resource #{common_args} composite_namevar php-gem ensure=absent")
65-
expect(stdout_str.strip).to match(/^composite_namevar \{ 'php-gem'/)
66-
expect(stdout_str.strip).to match(/package\s*=> 'php'/)
67-
expect(stdout_str.strip).to match(/manager\s*=> 'gem'/)
68-
expect(stdout_str.strip).to match(/ensure\s*=> 'absent'/)
69-
expect(stdout_str.strip).to match(/Looking for \[\{:package=>"php", :manager=>"gem"\}\]/)
57+
expect(stdout_str.strip).to match %r{^composite_namevar \{ \'php-gem\'}
58+
expect(stdout_str.strip).to match %r{package\s*=> \'php\'}
59+
expect(stdout_str.strip).to match %r{manager\s*=> \'gem\'}
60+
expect(stdout_str.strip).to match %r{ensure\s*=> \'absent\'}
61+
expect(stdout_str.strip).to match %r{Looking for \[\{:package=>"php", :manager=>"gem"\}\]}
7062
expect(status.exitstatus).to eq 0
7163
end
7264
end
7365

7466
describe 'using `puppet apply`' do
75-
let(:common_args) { "#{super()} --detailed-exitcodes" }
67+
let(:common_args) { super() + ' --detailed-exitcodes' }
7668

7769
# run Open3.capture2e only once to get both output, and exitcode
7870
# rubocop:disable RSpec/InstanceVariable
79-
before do
71+
before(:each) do
8072
Tempfile.create('acceptance') do |f|
8173
f.write(manifest)
8274
f.close
@@ -88,41 +80,41 @@
8880
context 'when managing a present instance' do
8981
let(:manifest) { 'composite_namevar { php-gem: }' }
9082

91-
it { expect(@stdout_str).to match(/Current State: \{:title=>"php-gem", :package=>"php", :manager=>"gem", :ensure=>"present", :value=>"b"\}/) }
92-
it { expect(@stdout_str).to match(/Looking for \[\{:package=>"php", :manager=>"gem"\}\]/) }
83+
it { expect(@stdout_str).to match %r{Current State: \{:title=>"php-gem", :package=>"php", :manager=>"gem", :ensure=>"present", :value=>"b"\}} }
84+
it { expect(@stdout_str).to match %r{Looking for \[\{:package=>"php", :manager=>"gem"\}\]} }
9385
it { expect(@status.exitstatus).to eq 0 }
9486
end
9587

9688
context 'when managing an absent instance' do
9789
let(:manifest) { 'composite_namevar { php-wibble: ensure=>\'absent\' }' }
9890

99-
it { expect(@stdout_str).to match(/Composite_namevar\[php-wibble\]: Nothing to manage: no ensure and the resource doesn't exist/) }
100-
it { expect(@stdout_str).to match(/Looking for \[\{:package=>"php", :manager=>"wibble"\}\]/) }
91+
it { expect(@stdout_str).to match %r{Composite_namevar\[php-wibble\]: Nothing to manage: no ensure and the resource doesn't exist} }
92+
it { expect(@stdout_str).to match %r{Looking for \[\{:package=>"php", :manager=>"wibble"\}\]} }
10193
it { expect(@status.exitstatus).to eq 0 }
10294
end
10395

10496
context 'when creating a previously absent instance' do
10597
let(:manifest) { 'composite_namevar { php-wibble: ensure=>\'present\' }' }
10698

10799
it { expect(@stdout_str).to match %r{Composite_namevar\[php-wibble\]/ensure: defined 'ensure' as 'present'} }
108-
it { expect(@stdout_str).to match(/Looking for \[\{:package=>"php", :manager=>"wibble"\}\]/) }
100+
it { expect(@stdout_str).to match %r{Looking for \[\{:package=>"php", :manager=>"wibble"\}\]} }
109101
it { expect(@status.exitstatus).to eq 2 }
110102
end
111103

112104
context 'when removing a previously present instance' do
113105
let(:manifest) { 'composite_namevar { php-yum: ensure=>\'absent\' }' }
114106

115107
it { expect(@stdout_str).to match %r{Composite_namevar\[php-yum\]/ensure: undefined 'ensure' from 'present'} }
116-
it { expect(@stdout_str).to match(/Looking for \[\{:package=>"php", :manager=>"yum"\}\]/) }
108+
it { expect(@stdout_str).to match %r{Looking for \[\{:package=>"php", :manager=>"yum"\}\]} }
117109
it { expect(@status.exitstatus).to eq 2 }
118110
end
119111

120112
context 'when modifying an existing resource through an alternative title_pattern' do
121113
let(:manifest) { 'composite_namevar { \'php/gem\': value=>\'c\' }' }
122114

123-
it { expect(@stdout_str).to match(/Current State: \{:title=>"php-gem", :package=>"php", :manager=>"gem", :ensure=>"present", :value=>"b"\}/) }
124-
it { expect(@stdout_str).to match(/Target State: \{:package=>"php", :manager=>"gem", :value=>"c", :ensure=>"present"\}/) }
125-
it { expect(@stdout_str).to match(/Looking for \[\{:package=>"php", :manager=>"gem"\}\]/) }
115+
it { expect(@stdout_str).to match %r{Current State: \{:title=>"php-gem", :package=>"php", :manager=>"gem", :ensure=>"present", :value=>"b"\}} }
116+
it { expect(@stdout_str).to match %r{Target State: \{:package=>"php", :manager=>"gem", :value=>"c", :ensure=>"present"\}} }
117+
it { expect(@stdout_str).to match %r{Looking for \[\{:package=>"php", :manager=>"gem"\}\]} }
126118
it { expect(@status.exitstatus).to eq 2 }
127119
end
128120
end
@@ -131,32 +123,32 @@
131123
context 'when managing a present instance' do
132124
let(:manifest) { 'composite_namevar { "sometitle": package => "php", manager => "gem" }' }
133125

134-
it { expect(@stdout_str).to match(/Current State: \{:title=>"php-gem", :package=>"php", :manager=>"gem", :ensure=>"present", :value=>"b"\}/) }
135-
it { expect(@stdout_str).to match(/Looking for \[\{:package=>"php", :manager=>"gem"\}\]/) }
126+
it { expect(@stdout_str).to match %r{Current State: \{:title=>"php-gem", :package=>"php", :manager=>"gem", :ensure=>"present", :value=>"b"\}} }
127+
it { expect(@stdout_str).to match %r{Looking for \[\{:package=>"php", :manager=>"gem"\}\]} }
136128
it { expect(@status.exitstatus).to eq 0 }
137129
end
138130

139131
context 'when managing an absent instance' do
140132
let(:manifest) { 'composite_namevar { "sometitle": ensure => "absent", package => "php", manager => "wibble" }' }
141133

142-
it { expect(@stdout_str).to match(/Composite_namevar\[sometitle\]: Nothing to manage: no ensure and the resource doesn't exist/) }
143-
it { expect(@stdout_str).to match(/Looking for \[\{:package=>"php", :manager=>"wibble"\}\]/) }
134+
it { expect(@stdout_str).to match %r{Composite_namevar\[sometitle\]: Nothing to manage: no ensure and the resource doesn't exist} }
135+
it { expect(@stdout_str).to match %r{Looking for \[\{:package=>"php", :manager=>"wibble"\}\]} }
144136
it { expect(@status.exitstatus).to eq 0 }
145137
end
146138

147139
context 'when creating a previously absent instance' do
148140
let(:manifest) { 'composite_namevar { "sometitle": ensure => "present", package => "php", manager => "wibble" }' }
149141

150142
it { expect(@stdout_str).to match %r{Composite_namevar\[sometitle\]/ensure: defined 'ensure' as 'present'} }
151-
it { expect(@stdout_str).to match(/Looking for \[\{:package=>"php", :manager=>"wibble"\}\]/) }
143+
it { expect(@stdout_str).to match %r{Looking for \[\{:package=>"php", :manager=>"wibble"\}\]} }
152144
it { expect(@status.exitstatus).to eq 2 }
153145
end
154146

155147
context 'when removing a previously present instance' do
156148
let(:manifest) { 'composite_namevar { "sometitle": ensure => "absent", package => "php", manager => "yum" }' }
157149

158150
it { expect(@stdout_str).to match %r{Composite_namevar\[sometitle\]/ensure: undefined 'ensure' from 'present'} }
159-
it { expect(@stdout_str).to match(/Looking for \[\{:package=>"php", :manager=>"yum"\}\]/) }
151+
it { expect(@stdout_str).to match %r{Looking for \[\{:package=>"php", :manager=>"yum"\}\]} }
160152
it { expect(@status.exitstatus).to eq 2 }
161153
end
162154
end

0 commit comments

Comments
 (0)