Skip to content

Commit 5433852

Browse files
author
David Swan
committed
RubocopFinished
1 parent 2c9846d commit 5433852

File tree

1 file changed

+13
-75
lines changed

1 file changed

+13
-75
lines changed

spec/unit/puppet/provider/file_line/ruby_spec_alter.rb

Lines changed: 13 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
end
147147
end
148148
end
149-
# rubocop:enable RSpec/InstanceVariable : replacing before with let breaks the tests : multi
150149
context 'when match+replace+append_on_no_match' do
151150
pending('to do')
152151
end
@@ -181,6 +180,7 @@
181180
before :each do
182181
File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2\nfoo = baz") }
183182
end
183+
# rubocop:disable RSpec/NestedGroups : Reducing the nesting would needlesly complicate the code
184184
describe 'inserts at match' do
185185
include_context 'resource_create'
186186
it {
@@ -228,15 +228,8 @@
228228
end
229229

230230
it 'adds the line after all lines matching the after expression' do
231-
@resource = Puppet::Type::File_line.new(
232-
name: 'foo',
233-
path: tmpfile,
234-
line: 'inserted = line',
235-
after: '^foo1$',
236-
multiple: true,
237-
)
231+
@resource = Puppet::Type::File_line.new(name: 'foo', path: tmpfile, line: 'inserted = line', after: '^foo1$', multiple: true)
238232
@provider = provider_class.new(@resource)
239-
expect(@provider.exists?).to be false
240233
@provider.create
241234
expect(File.read(tmpfile).chomp).to eql("foo1\ninserted = line\nfoo = blah\nfoo2\nfoo1\ninserted = line\nfoo = baz")
242235
end
@@ -285,12 +278,7 @@
285278
expect(File.read(tmpfile)).to eql("foo1\nfoo2\n")
286279
end
287280
it 'example in the docs' do
288-
@resource = Puppet::Type::File_line.new(
289-
name: 'bashrc_proxy',
290-
ensure: 'absent',
291-
path: tmpfile,
292-
line: 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
293-
)
281+
@resource = Puppet::Type::File_line.new(name: 'bashrc_proxy', ensure: 'absent', path: tmpfile, line: 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128')
294282
@provider = provider_class.new(@resource)
295283
File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2\nexport HTTP_PROXY=http://squid.puppetlabs.vm:3128\nfoo4\n") }
296284
@provider.destroy
@@ -322,32 +310,17 @@
322310
end
323311

324312
it 'the line parameter is actually not used at all but is silently ignored if here' do
325-
@resource = Puppet::Type::File_line.new(
326-
name: 'foo',
327-
path: tmpfile,
328-
line: 'supercalifragilisticexpialidocious',
329-
ensure: 'absent',
330-
match: 'o$',
331-
match_for_absence: true,
332-
)
313+
@resource = Puppet::Type::File_line.new(name: 'foo', path: tmpfile, line: 'supercalifragilisticexpialidocious', ensure: 'absent', match: 'o$', match_for_absence: true)
333314
@provider = provider_class.new(@resource)
334315
File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") }
335-
expect(@provider.exists?).to be true
336316
@provider.destroy
337317
expect(File.read(tmpfile)).to eql("foo1\nfoo2")
338318
end
339319

340320
it 'and may not be here and does not need to be here' do
341-
@resource = Puppet::Type::File_line.new(
342-
name: 'foo',
343-
path: tmpfile,
344-
ensure: 'absent',
345-
match: 'o$',
346-
match_for_absence: true,
347-
)
321+
@resource = Puppet::Type::File_line.new(name: 'foo', path: tmpfile, ensure: 'absent', match: 'o$', match_for_absence: true)
348322
@provider = provider_class.new(@resource)
349323
File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") }
350-
expect(@provider.exists?).to be true
351324
@provider.destroy
352325
expect(File.read(tmpfile)).to eql("foo1\nfoo2")
353326
end
@@ -358,82 +331,47 @@
358331
end
359332

360333
it 'removes multiple lines if :multiple is true' do
361-
@resource = Puppet::Type::File_line.new(
362-
name: 'foo',
363-
path: tmpfile,
364-
line: 'foo2',
365-
ensure: 'absent',
366-
match: 'o$',
367-
multiple: true,
368-
match_for_absence: true,
369-
)
334+
@resource = Puppet::Type::File_line.new(name: 'foo', path: tmpfile, line: 'foo2', ensure: 'absent', match: 'o$', multiple: true, match_for_absence: true)
370335
@provider = provider_class.new(@resource)
371336
File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2\nfoo\nfoo") }
372-
expect(@provider.exists?).to be true
373337
@provider.destroy
374338
expect(File.read(tmpfile)).to eql("foo1\nfoo2\n")
375339
end
376340

377341
it 'ignores the match if match_for_absence is not specified' do
378-
@resource = Puppet::Type::File_line.new(
379-
name: 'foo',
380-
path: tmpfile,
381-
line: 'foo2',
382-
ensure: 'absent',
383-
match: 'o$',
384-
)
342+
@resource = Puppet::Type::File_line.new(name: 'foo', path: tmpfile, line: 'foo2', ensure: 'absent', match: 'o$')
385343
@provider = provider_class.new(@resource)
386344
File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") }
387-
expect(@provider.exists?).to be true
388345
@provider.destroy
389346
expect(File.read(tmpfile)).to eql("foo1\nfoo\n")
390347
end
391348

392349
it 'ignores the match if match_for_absence is false' do
393-
@resource = Puppet::Type::File_line.new(
394-
name: 'foo',
395-
path: tmpfile,
396-
line: 'foo2',
397-
ensure: 'absent',
398-
match: 'o$',
399-
match_for_absence: false,
400-
)
350+
@resource = Puppet::Type::File_line.new(name: 'foo', path: tmpfile, line: 'foo2', ensure: 'absent', match: 'o$', match_for_absence: false)
401351
@provider = provider_class.new(@resource)
402352
File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo\nfoo2") }
403-
expect(@provider.exists?).to be true
404353
@provider.destroy
405354
expect(File.read(tmpfile)).to eql("foo1\nfoo\n")
406355
end
407356

408-
it 'example in the docs' do
357+
it 'example in the docs' do # rubocop:disable RSpec/ExampleLength : Cannot reduce without violating line length rule
409358
@resource = Puppet::Type::File_line.new(
410-
name: 'bashrc_proxy',
411-
ensure: 'absent',
412-
path: tmpfile,
413-
line: 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
414-
match: '^export\ HTTP_PROXY\=',
415-
match_for_absence: true,
359+
name: 'bashrc_proxy', ensure: 'absent', path: tmpfile, line: 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
360+
match: '^export\ HTTP_PROXY\=', match_for_absence: true
416361
)
417362
@provider = provider_class.new(@resource)
418363
File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2\nexport HTTP_PROXY=foo\nfoo4\n") }
419-
expect(@provider.exists?).to be true
420364
@provider.destroy
421365
expect(File.read(tmpfile)).to eql("foo1\nfoo2\nfoo4\n")
422366
end
423367

424368
it 'example in the docs showing line is redundant' do
425-
@resource = Puppet::Type::File_line.new(
426-
name: 'bashrc_proxy',
427-
ensure: 'absent',
428-
path: tmpfile,
429-
match: '^export\ HTTP_PROXY\=',
430-
match_for_absence: true,
431-
)
369+
@resource = Puppet::Type::File_line.new(name: 'bashrc_proxy', ensure: 'absent', path: tmpfile, match: '^export\ HTTP_PROXY\=', match_for_absence: true)
432370
@provider = provider_class.new(@resource)
433371
File.open(tmpfile, 'w') { |fh| fh.write("foo1\nfoo2\nexport HTTP_PROXY=foo\nfoo4\n") }
434-
expect(@provider.exists?).to be true
435372
@provider.destroy
436373
expect(File.read(tmpfile)).to eql("foo1\nfoo2\nfoo4\n")
437374
end
438375
end
376+
# rubocop:enable RSpec/InstanceVariable : multi
439377
end

0 commit comments

Comments
 (0)