diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4b05ede8..1f63d1a9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -40,19 +40,6 @@ Metrics/MethodLength: Metrics/PerceivedComplexity: Max: 20 -# Offense count: 114 -# Configuration parameters: ForbiddenDelimiters. -# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) -Naming/HeredocDelimiterNaming: - Exclude: - - 'lib/puppet/type/ini_subsetting.rb' - - 'spec/acceptance/ini_setting_spec.rb' - - 'spec/acceptance/ini_subsetting_spec.rb' - - 'spec/unit/puppet/provider/ini_setting/inheritance_spec.rb' - - 'spec/unit/puppet/provider/ini_setting/ruby_spec.rb' - - 'spec/unit/puppet/provider/ini_subsetting/ruby_spec.rb' - - 'spec/unit/puppet/util/ini_file_spec.rb' - # Offense count: 12 # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: @@ -98,13 +85,3 @@ RSpec/NamedSubject: RSpec/NestedGroups: Max: 6 -# Offense count: 4 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Exclude: - - 'lib/puppet/util/external_iterator.rb' - - 'lib/puppet/util/ini_file.rb' - - 'lib/puppet/util/ini_file/section.rb' - - 'lib/puppet/util/setting_value.rb' diff --git a/lib/puppet/type/ini_subsetting.rb b/lib/puppet/type/ini_subsetting.rb index 38589411..184c4613 100644 --- a/lib/puppet/type/ini_subsetting.rb +++ b/lib/puppet/type/ini_subsetting.rb @@ -104,7 +104,7 @@ def is_to_s(value) # rubocop:disable Naming/PredicateName : Changing breaks the end newparam(:insert_type) do - desc <<-EOF + desc <<-DOCUMENTATION Where the new subsetting item should be inserted * :start - insert at the beginning of the line. @@ -112,7 +112,7 @@ def is_to_s(value) # rubocop:disable Naming/PredicateName : Changing breaks the * :before - insert before the specified element if possible. * :after - insert after the specified element if possible. * :index - insert at the specified index number. - EOF + DOCUMENTATION newvalues(:start, :end, :before, :after, :index) defaultto(:end) diff --git a/lib/puppet/util/external_iterator.rb b/lib/puppet/util/external_iterator.rb index 0a6b2359..19185afb 100644 --- a/lib/puppet/util/external_iterator.rb +++ b/lib/puppet/util/external_iterator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Puppet::Util +module Puppet::Util # rubocop:disable Style/ClassAndModuleChildren # # external_iterator.rb # diff --git a/lib/puppet/util/ini_file.rb b/lib/puppet/util/ini_file.rb index 1636479f..97e165e1 100644 --- a/lib/puppet/util/ini_file.rb +++ b/lib/puppet/util/ini_file.rb @@ -3,7 +3,7 @@ require File.expand_path('external_iterator', __dir__) require File.expand_path('ini_file/section', __dir__) -module Puppet::Util +module Puppet::Util # rubocop:disable Style/ClassAndModuleChildren # # ini_file.rb # diff --git a/lib/puppet/util/ini_file/section.rb b/lib/puppet/util/ini_file/section.rb index 75ea5448..46e01477 100644 --- a/lib/puppet/util/ini_file/section.rb +++ b/lib/puppet/util/ini_file/section.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class Puppet::Util::IniFile +class Puppet::Util::IniFile # rubocop:disable Style/ClassAndModuleChildren # # section.rb # diff --git a/lib/puppet/util/setting_value.rb b/lib/puppet/util/setting_value.rb index fb1c4741..28d17e75 100644 --- a/lib/puppet/util/setting_value.rb +++ b/lib/puppet/util/setting_value.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Puppet::Util +module Puppet::Util # rubocop:disable Style/ClassAndModuleChildren # This class can work with a list of subsettings inside # an ini file setting string to add, remove, extract and set their values. class SettingValue diff --git a/spec/acceptance/ini_setting_spec.rb b/spec/acceptance/ini_setting_spec.rb index 3e70ccbf..140a35e5 100644 --- a/spec/acceptance/ini_setting_spec.rb +++ b/spec/acceptance/ini_setting_spec.rb @@ -44,7 +44,7 @@ end context 'when ensure parameter => present for global and section' do - pp = <<-EOS + pp = <<-MANIFEST ini_setting { 'ensure => present for section': ensure => present, path => "#{basedir}/ini_setting.ini", @@ -59,7 +59,7 @@ setting => 'four', value => 'five', } - EOS + MANIFEST it_behaves_like 'has_content', "#{basedir}/ini_setting.ini", pp, %r{four = five\R\R\[one\]\Rtwo = three} end @@ -76,7 +76,7 @@ apply_manifest(ipp) end - pp = <<-EOS + pp = <<-MANIFEST ini_setting { 'ensure => absent for key/value': ensure => absent, path => "#{basedir}/ini_setting.ini", @@ -84,7 +84,7 @@ setting => 'two', value => 'three', } - EOS + MANIFEST it 'applies the manifest twice' do expect { idempotent_apply(pp) }.not_to raise_error @@ -119,7 +119,7 @@ run_shell("rm #{basedir}/ini_setting.ini", expect_failures: true) end - pp = <<-EOS + pp = <<-MANIFEST ini_setting { 'ensure => absent for global': ensure => absent, path => "#{basedir}/ini_setting.ini", @@ -127,7 +127,7 @@ setting => 'four', value => 'five', } - EOS + MANIFEST it 'applies the manifest twice' do expect { idempotent_apply(pp) }.not_to raise_error @@ -148,7 +148,7 @@ describe 'path parameter' do context 'when path => foo' do - pp = <<-EOS + pp = <<-MANIFEST ini_setting { 'path => foo': ensure => present, section => 'one', @@ -156,20 +156,20 @@ value => 'three', path => 'foo', } - EOS + MANIFEST it_behaves_like 'has_error', 'foo', pp, %r{must be fully qualified} end end context 'when ensure parameter => present and only section' do - pp = <<-EOS + pp = <<-MANIFEST ini_setting { 'ensure => present for section': ensure => present, path => "#{basedir}/ini_setting.ini", section => 'one', } - EOS + MANIFEST it_behaves_like 'has_content', "#{basedir}/ini_setting.ini", pp, %r{\[one\]} end @@ -181,7 +181,7 @@ { value: 'public_value', matcher: %r{initial_value.*public_value}, show_diff: true }, { value: 'secret_value', matcher: %r{redacted sensitive information.*redacted sensitive information}, show_diff: false }, { value: 'md5_value', matcher: %r{\{md5\}881671aa2bbc680bc530c4353125052b.*\{md5\}ed0903a7fa5de7886ca1a7a9ad06cf51}, show_diff: :md5 }].each do |i| - pp = <<-EOS + pp = <<-MANIFEST ini_setting { 'test_show_diff': ensure => present, section => 'test', @@ -190,7 +190,7 @@ path => "#{basedir}/test_show_diff.ini", show_diff => #{i[:show_diff]} } - EOS + MANIFEST context "when show_diff => #{i[:show_diff]}" do res = apply_manifest(pp, expect_changes: true) @@ -206,7 +206,7 @@ end describe 'values with spaces in the value part at the beginning or at the end' do - pp = <<-EOS + pp = <<-MANIFEST ini_setting { 'path => foo': ensure => present, section => 'one', @@ -214,7 +214,7 @@ value => ' 123', path => '#{basedir}/ini_setting.ini', } - EOS + MANIFEST it_behaves_like 'has_content', "#{basedir}/ini_setting.ini", pp, %r{\[one\]\Rtwo = 123} end @@ -238,7 +238,7 @@ context 'when event is triggered' do context 'when update setting value' do let(:update_value_manifest) do - <<-EOS + <<-MANIFEST notify { foo: notify => Ini_Setting['updateSetting'], } @@ -251,7 +251,7 @@ value => "newValue", refreshonly => true, } - EOS + MANIFEST end before(:each) do @@ -271,7 +271,7 @@ context 'when remove setting value' do let(:remove_setting_manifest) do - <<-EOS + <<-MANIFEST notify { foo: notify => Ini_Setting['removeSetting'], } @@ -283,7 +283,7 @@ setting => 'valueinsection1', refreshonly => true, } - EOS + MANIFEST end before(:each) do @@ -305,7 +305,7 @@ context 'when not receiving an event' do context 'when does not update setting' do let(:does_not_update_value_manifest) do - <<-EOS + <<-MANIFEST file { "#{basedir}/ini_setting.ini": ensure => present, notify => Ini_Setting['updateSetting'], @@ -318,7 +318,7 @@ value => "newValue", refreshonly => true, } - EOS + MANIFEST end before(:each) do @@ -339,7 +339,7 @@ context 'when does not remove setting' do let(:does_not_remove_setting_manifest) do - <<-EOS + <<-MANIFEST file { "#{basedir}/ini_setting.ini": ensure => present, notify => Ini_Setting['removeSetting'], @@ -352,7 +352,7 @@ setting => 'valueinsection1', refreshonly => true, } - EOS + MANIFEST end before(:each) do diff --git a/spec/acceptance/ini_subsetting_spec.rb b/spec/acceptance/ini_subsetting_spec.rb index e1548f57..302f37a4 100644 --- a/spec/acceptance/ini_subsetting_spec.rb +++ b/spec/acceptance/ini_subsetting_spec.rb @@ -46,7 +46,7 @@ end describe 'ensure, section, setting, subsetting, & value parameters => present with subsections' do - pp = <<-EOS + pp = <<-MANIFEST ini_subsetting { 'ensure => present for alpha': ensure => present, path => "#{basedir}/ini_subsetting.ini", @@ -64,7 +64,7 @@ value => 'trons', require => Ini_subsetting['ensure => present for alpha'], } - EOS + MANIFEST describe file("#{basedir}/ini_subsetting.ini") do it_behaves_like 'has_content', "#{basedir}/ini_subsetting.ini", pp, %r{\[one\]\Rkey = alphabet betatrons} @@ -72,7 +72,7 @@ end describe 'ensure => absent' do - pp = <<-EOS + pp = <<-MANIFEST ini_subsetting { 'ensure => absent for subsetting': ensure => absent, path => "#{basedir}/ini_subsetting.ini", @@ -80,7 +80,7 @@ setting => 'key', subsetting => 'alpha', } - EOS + MANIFEST it 'applies the manifest twice' do expect { idempotent_apply(pp) }.not_to raise_error @@ -100,7 +100,7 @@ end describe 'delete_if_empty => true' do - pp = <<-EOS + pp = <<-MANIFEST ini_subsetting { 'ensure => absent for alpha': ensure => absent, path => "#{basedir}/ini_subsetting.ini", @@ -117,7 +117,7 @@ subsetting => 'beta', delete_if_empty => true, } - EOS + MANIFEST it 'applies the manifest twice' do run_shell("echo -e [one]\\\\nkey = alphabet betatrons > #{basedir}/ini_subsetting.ini", expect_failures: true) @@ -163,7 +163,7 @@ run_shell("rm #{path}", expect_failures: true) end - pp = <<-EOS + pp = <<-MANIFEST ini_subsetting { '#{parameter.first}': ensure => #{(parameter.length > 1) ? 'present' : 'absent'}, path => '#{path}', @@ -173,7 +173,7 @@ subsetting => '#{parameter.first}', value => '#{(parameter.length > 1) ? parameter[1] : ''}' } - EOS + MANIFEST it 'applies the manifest twice' do expect { idempotent_apply(pp) }.not_to raise_error @@ -199,7 +199,7 @@ { value: 'public_value', matcher: %r{initial_value.*public_value}, show_diff: true }, { value: 'secret_value', matcher: %r{redacted sensitive information.*redacted sensitive information}, show_diff: false }, { value: 'md5_value', matcher: %r{\{md5\}881671aa2bbc680bc530c4353125052b.*\{md5\}ed0903a7fa5de7886ca1a7a9ad06cf51}, show_diff: :md5 }].each do |i| - pp = <<-EOS + pp = <<-MANIFEST ini_subsetting { 'test_show_diff': ensure => present, section => 'test', @@ -209,7 +209,7 @@ path => "#{basedir}/test_show_diff.ini", show_diff => #{i[:show_diff]} } - EOS + MANIFEST context "when show_diff => #{i[:show_diff]}" do res = apply_manifest(pp, expect_changes: true) @@ -251,7 +251,7 @@ }, ].each do |params| context "with '#{params[:insert_type]}' makes '#{params[:content]}'" do - pp = <<-EOS + pp = <<-MANIFEST ini_subsetting { "a": ensure => present, section => 'one', @@ -282,7 +282,7 @@ insert_type => '#{params[:insert_type]}', insert_value => '#{params[:insert_value]}', } - EOS + MANIFEST it_behaves_like 'has_content', "#{basedir}/insert_types.ini", pp, params[:content] end diff --git a/spec/unit/puppet/provider/ini_setting/inheritance_spec.rb b/spec/unit/puppet/provider/ini_setting/inheritance_spec.rb index 42e1952f..7059eb2f 100644 --- a/spec/unit/puppet/provider/ini_setting/inheritance_spec.rb +++ b/spec/unit/puppet/provider/ini_setting/inheritance_spec.rb @@ -29,11 +29,11 @@ def validate_file(expected_content, tmpfile) context 'when the file has contents' do let(:orig_content) do - <<-EOS + <<-INIFILE # A comment red = blue green = purple - EOS + INIFILE end it 'parses the results' do diff --git a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb index 3015079f..09b17926 100644 --- a/spec/unit/puppet/provider/ini_setting/ruby_spec.rb +++ b/spec/unit/puppet/provider/ini_setting/ruby_spec.rb @@ -63,7 +63,7 @@ def self.file_path context 'when file has contecnts' do let(:orig_content) do - <<-EOS + <<-INIFILE # This is a comment [section1] ; This is also a comment @@ -80,7 +80,7 @@ def self.file_path subby=bar #another comment ; yet another comment - EOS + INIFILE end it 'is able to parse the results' do @@ -116,7 +116,7 @@ def self.file_path context 'when ensuring that a setting is present' do let(:orig_content) do - <<~EOS + <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -136,10 +136,10 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -160,7 +160,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'adds a missing setting to the correct section' do resource = Puppet::Type::Ini_setting.new(common_params.merge(setting: 'yahoo', value: 'yippee')) provider = described_class.new(resource) @@ -169,7 +169,7 @@ def self.file_path validate_file(expected_content_one, tmpfile) end - expected_content_two = <<~EOS + expected_content_two = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -190,7 +190,7 @@ def self.file_path -nonstandard- shoes = purple yahoo = yippee - EOS + INIFILE it 'adds a missing setting to the correct section with pre/suffix' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'nonstandard', setting: 'yahoo', value: 'yippee', section_prefix: '-', section_suffix: '-')) provider = described_class.new(resource) @@ -199,7 +199,7 @@ def self.file_path validate_file(expected_content_two, tmpfile) end - expected_content_three = <<~EOS + expected_content_three = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -220,7 +220,7 @@ def self.file_path -nonstandard- shoes = purple indented = weirdly - EOS + INIFILE it 'adds a missing setting to the correct section with indent_char' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'nonstandard', setting: 'indented', value: 'weirdly', section_prefix: '-', section_suffix: '-', indent_char: "\t")) provider = described_class.new(resource) @@ -229,7 +229,7 @@ def self.file_path validate_file(expected_content_three, tmpfile) end - expected_content_four = <<~EOS + expected_content_four = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -250,7 +250,7 @@ def self.file_path -nonstandard- shoes = purple indented = weirdly - EOS + INIFILE it 'adds a missing setting to the correct section indented by indent_char * indent_width' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'nonstandard', setting: 'indented', value: 'weirdly', section_prefix: '-', section_suffix: '-', indent_char: "\t", indent_width: 4)) @@ -260,7 +260,7 @@ def self.file_path validate_file(expected_content_four, tmpfile) end - expected_content_five = <<~EOS + expected_content_five = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -281,7 +281,7 @@ def self.file_path -nonstandard- shoes = purple indented = weirdly - EOS + INIFILE it 'treats a string indent_width as an integer' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'nonstandard', setting: 'indented', value: 'weirdly', section_prefix: '-', section_suffix: '-', indent_char: "\t", indent_width: '4')) @@ -291,7 +291,7 @@ def self.file_path validate_file(expected_content_five, tmpfile) end - expected_content_six = <<~EOS + expected_content_six = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -312,7 +312,7 @@ def self.file_path -nonstandard- shoes = purple yahoo = yippee - EOS + INIFILE it 'adds a missing setting to the correct section with colon' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section:sub', setting: 'yahoo', value: 'yippee')) provider = described_class.new(resource) @@ -321,7 +321,7 @@ def self.file_path validate_file(expected_content_six, tmpfile) end - expected_content_seven = <<~EOS + expected_content_seven = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -341,7 +341,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'modifies an existing setting with a different value' do resource = Puppet::Type::Ini_setting.new(common_params.merge(setting: 'baz', value: 'bazvalue2')) provider = described_class.new(resource) @@ -350,7 +350,7 @@ def self.file_path validate_file(expected_content_seven, tmpfile) end - expected_content_eight = <<~EOS + expected_content_eight = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -370,7 +370,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'modifies an existing setting with a different boolean value' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section1', setting: 'main', value: false)) provider = described_class.new(resource) @@ -380,7 +380,7 @@ def self.file_path validate_file(expected_content_eight, tmpfile) end - expected_content_nine = <<~EOS + expected_content_nine = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -400,7 +400,7 @@ def self.file_path -nonstandard- shoes = orange - EOS + INIFILE it 'modifies an existing setting with pre/suffix with a different value' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'nonstandard', setting: 'shoes', value: 'orange', section_prefix: '-', section_suffix: '-')) provider = described_class.new(resource) @@ -409,7 +409,7 @@ def self.file_path validate_file(expected_content_nine, tmpfile) end - expected_content_ten = <<~EOS + expected_content_ten = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -429,7 +429,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'modifies an existing setting with a different value - with colon in section' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section:sub', setting: 'subby', value: 'foo')) provider = described_class.new(resource) @@ -438,7 +438,7 @@ def self.file_path validate_file(expected_content_ten, tmpfile) end - expected_content_eleven = <<~EOS + expected_content_eleven = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -458,7 +458,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'is able to handle settings with non alphanumbering settings' do resource = Puppet::Type::Ini_setting.new(common_params.merge(setting: 'url', value: 'http://192.168.0.1:8080')) provider = described_class.new(resource) @@ -467,7 +467,7 @@ def self.file_path validate_file(expected_content_eleven, tmpfile) end - expected_content_twelve = <<~EOS + expected_content_twelve = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -487,7 +487,7 @@ def self.file_path -nonstandard- shoes = http://192.168.0.1:8080 - EOS + INIFILE it 'is able to handle settings with pre/suffix with non alphanumbering settings' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'nonstandard', setting: 'shoes', value: 'http://192.168.0.1:8080', section_prefix: '-', section_suffix: '-')) provider = described_class.new(resource) @@ -509,7 +509,7 @@ def self.file_path expect(provider.exists?).to be true end - expected_content_thirteen = <<~EOS + expected_content_thirteen = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -532,7 +532,7 @@ def self.file_path [section3] huzzah = shazaam - EOS + INIFILE it 'adds a new section if the section does not exist' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section3', setting: 'huzzah', value: 'shazaam')) provider = described_class.new(resource) @@ -541,7 +541,7 @@ def self.file_path validate_file(expected_content_thirteen, tmpfile) end - expected_content_fourteen = <<~EOS + expected_content_fourteen = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -564,7 +564,7 @@ def self.file_path -section3- huzzah = shazaam - EOS + INIFILE it 'adds a new section with pre/suffix if the section does not exist' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section3', setting: 'huzzah', value: 'shazaam', section_prefix: '-', section_suffix: '-')) provider = described_class.new(resource) @@ -573,7 +573,7 @@ def self.file_path validate_file(expected_content_fourteen, tmpfile) end - expected_content_fifteen = <<~EOS + expected_content_fifteen = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -596,7 +596,7 @@ def self.file_path [section:subsection] huzzah = shazaam - EOS + INIFILE it 'adds a new section if the section does not exist - with colon' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section:subsection', setting: 'huzzah', value: 'shazaam')) provider = described_class.new(resource) @@ -605,7 +605,7 @@ def self.file_path validate_file(expected_content_fifteen, tmpfile) end - expected_content_sixteen = <<~EOS + expected_content_sixteen = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -628,7 +628,7 @@ def self.file_path -section:subsection- huzzah = shazaam - EOS + INIFILE it 'adds a new section with pre/suffix if the section does not exist - with colon' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section:subsection', setting: 'huzzah', value: 'shazaam', section_prefix: '-', section_suffix: '-')) provider = described_class.new(resource) @@ -735,23 +735,23 @@ def self.file_path context 'when dealing with a global section' do let(:orig_content) do - <<~EOS + <<~INIFILE # This is a comment foo=blah [section2] foo = http://192.168.1.1:8080 ; yet another comment - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE # This is a comment foo=blah bar = yippee [section2] foo = http://192.168.1.1:8080 ; yet another comment - EOS + INIFILE it "adds a missing setting if it doesn't exist" do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: '', setting: 'bar', value: 'yippee')) provider = described_class.new(resource) @@ -760,13 +760,13 @@ def self.file_path validate_file(expected_content_one, tmpfile) end - expected_content_two = <<~EOS + expected_content_two = <<~INIFILE # This is a comment foo=yippee [section2] foo = http://192.168.1.1:8080 ; yet another comment - EOS + INIFILE it 'modifies an existing setting with a different value' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: '', setting: 'foo', value: 'yippee')) provider = described_class.new(resource) @@ -784,18 +784,18 @@ def self.file_path context 'when the first line of the file is a section' do let(:orig_content) do - <<~EOS + <<~INIFILE [section2] foo = http://192.168.1.1:8080 - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE foo = yippee [section2] foo = http://192.168.1.1:8080 - EOS + INIFILE it 'is able to add a global setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: '', setting: 'foo', value: 'yippee')) provider = described_class.new(resource) @@ -804,10 +804,10 @@ def self.file_path validate_file(expected_content_one, tmpfile) end - expected_content_two = <<~EOS + expected_content_two = <<~INIFILE [section2] foo = yippee - EOS + INIFILE it 'modifies an existing setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'foo', value: 'yippee')) provider = described_class.new(resource) @@ -816,11 +816,11 @@ def self.file_path validate_file(expected_content_two, tmpfile) end - expected_content_three = <<~EOS + expected_content_three = <<~INIFILE [section2] foo = http://192.168.1.1:8080 bar = baz - EOS + INIFILE it 'adds a new setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'bar', value: 'baz')) provider = described_class.new(resource) @@ -832,16 +832,16 @@ def self.file_path context 'when overriding the separator' do let(:orig_content) do - <<~EOS + <<~INIFILE [section2] foo=bar - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE [section2] foo=yippee - EOS + INIFILE it 'modifies an existing setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'foo', value: 'yippee', key_val_separator: '=')) provider = described_class.new(resource) @@ -853,16 +853,16 @@ def self.file_path context 'when overriding the separator to something other than =' do let(:orig_content) do - <<~EOS + <<~INIFILE [section2] foo: bar - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE [section2] foo: yippee - EOS + INIFILE it 'modifies an existing setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'foo', value: 'yippee', key_val_separator: ': ')) provider = described_class.new(resource) @@ -871,11 +871,11 @@ def self.file_path validate_file(expected_content_one, tmpfile) end - expected_content_two = <<~EOS + expected_content_two = <<~INIFILE [section2] foo: bar bar: baz - EOS + INIFILE it 'adds a new setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'bar', value: 'baz', key_val_separator: ': ')) provider = described_class.new(resource) @@ -887,16 +887,16 @@ def self.file_path context 'when overriding the separator to a space' do let(:orig_content) do - <<~EOS + <<~INIFILE [section2] foo bar - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE [section2] foo yippee - EOS + INIFILE it 'modifies an existing setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'foo', value: 'yippee', key_val_separator: ' ')) provider = described_class.new(resource) @@ -905,11 +905,11 @@ def self.file_path validate_file(expected_content_one, tmpfile) end - expected_content_two = <<~EOS + expected_content_two = <<~INIFILE [section2] foo bar bar baz - EOS + INIFILE it 'adds a new setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'bar', value: 'baz', key_val_separator: ' ')) provider = described_class.new(resource) @@ -921,7 +921,7 @@ def self.file_path context 'when ensuring that a setting is absent' do let(:orig_content) do - <<~EOS + <<~INIFILE [section1] ; This is also a comment foo=foovalue @@ -945,10 +945,10 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE [section1] ; This is also a comment @@ -971,7 +971,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'removes a setting that exists' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section1', setting: 'foo', ensure: 'absent')) provider = described_class.new(resource) @@ -980,7 +980,7 @@ def self.file_path validate_file(expected_content_one, tmpfile) end - expected_content_two = <<~EOS + expected_content_two = <<~INIFILE [section1] ; This is also a comment foo=foovalue @@ -1002,7 +1002,7 @@ def self.file_path #another comment ; yet another comment - EOS + INIFILE it 'removes a setting with pre/suffix that exists' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'nonstandard', setting: 'shoes', ensure: 'absent', section_prefix: '-', section_suffix: '-')) provider = described_class.new(resource) @@ -1011,7 +1011,7 @@ def self.file_path validate_file(expected_content_two, tmpfile) end - expected_content_three = <<~EOS + expected_content_three = <<~INIFILE [section1] ; This is also a comment foo=foovalue @@ -1035,7 +1035,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'does nothing for a setting that does not exist' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section:sub', setting: 'foo', ensure: 'absent')) provider = described_class.new(resource) @@ -1044,7 +1044,7 @@ def self.file_path validate_file(expected_content_three, tmpfile) end - expected_content_four = <<~EOS + expected_content_four = <<~INIFILE [section1] ; This is also a comment foo=foovalue @@ -1068,7 +1068,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'does nothing for a setting with pre/suffix that does not exist' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'nonstandard', setting: 'foo', ensure: 'absent', section_prefix: '-', section_suffix: '-')) provider = described_class.new(resource) @@ -1077,7 +1077,7 @@ def self.file_path validate_file(expected_content_four, tmpfile) end - expected_content_five = <<~EOS + expected_content_five = <<~INIFILE [section1] ; This is also a comment foo=foovalue @@ -1100,7 +1100,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'does not remove a section when the last uncommented setting is removed if there are comments' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section3', setting: 'uncom', ensure: 'absent')) provider = described_class.new(resource) @@ -1109,7 +1109,7 @@ def self.file_path validate_file(expected_content_five, tmpfile) end - expected_content_six = <<~EOS + expected_content_six = <<~INIFILE [section1] ; This is also a comment foo=foovalue @@ -1131,7 +1131,7 @@ def self.file_path -nonstandard- shoes = purple - EOS + INIFILE it 'removes the section when removing the last line in the section' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section4', setting: 'uncom', ensure: 'absent')) provider = described_class.new(resource) @@ -1143,7 +1143,7 @@ def self.file_path context 'when dealing with indentation in sections' do let(:orig_content) do - <<~EOS + <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -1161,10 +1161,10 @@ def self.file_path #another comment fleezy = flam ; yet another comment - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -1183,7 +1183,7 @@ def self.file_path #another comment fleezy = flam ; yet another comment - EOS + INIFILE it 'adds a missing setting at the correct indentation when the header is aligned' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section1', setting: 'yahoo', value: 'yippee')) provider = described_class.new(resource) @@ -1192,7 +1192,7 @@ def self.file_path validate_file(expected_content_one, tmpfile) end - expected_content_two = <<~EOS + expected_content_two = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -1210,7 +1210,7 @@ def self.file_path #another comment fleezy = flam ; yet another comment - EOS + INIFILE it 'updates an existing setting at the correct indentation when the header is aligned' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section1', setting: 'bar', value: 'barvalue2')) provider = described_class.new(resource) @@ -1219,7 +1219,7 @@ def self.file_path validate_file(expected_content_two, tmpfile) end - expected_content_three = <<~EOS + expected_content_three = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -1238,7 +1238,7 @@ def self.file_path #another comment fleezy = flam ; yet another comment - EOS + INIFILE it 'adds a missing setting at the correct indentation when the header is not aligned' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'yahoo', value: 'yippee')) provider = described_class.new(resource) @@ -1247,7 +1247,7 @@ def self.file_path validate_file(expected_content_three, tmpfile) end - expected_content_four = <<~EOS + expected_content_four = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -1265,7 +1265,7 @@ def self.file_path #another comment fleezy = flam ; yet another comment - EOS + INIFILE it 'updates an existing setting at the correct indentation when the header is not aligned' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'baz', value: 'bazvalue2')) provider = described_class.new(resource) @@ -1274,7 +1274,7 @@ def self.file_path validate_file(expected_content_four, tmpfile) end - expected_content_five = <<~EOS + expected_content_five = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -1293,7 +1293,7 @@ def self.file_path fleezy = flam ; yet another comment yahoo = yippee - EOS + INIFILE it 'adds a missing setting at the min indentation when the section is not aligned' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section:sub', setting: 'yahoo', value: 'yippee')) provider = described_class.new(resource) @@ -1302,7 +1302,7 @@ def self.file_path validate_file(expected_content_five, tmpfile) end - expected_content_six = <<~EOS + expected_content_six = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -1320,7 +1320,7 @@ def self.file_path #another comment fleezy = flam2 ; yet another comment - EOS + INIFILE it 'updates an existing setting at the previous indentation when the section is not aligned' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section:sub', setting: 'fleezy', value: 'flam2')) provider = described_class.new(resource) @@ -1329,7 +1329,7 @@ def self.file_path validate_file(expected_content_six, tmpfile) end - expected_content_seven = <<~EOS + expected_content_seven = <<~INIFILE # This is a comment [section1] ; This is also a comment @@ -1347,7 +1347,7 @@ def self.file_path #another comment fleezy = flam2 ; yet another comment - EOS + INIFILE it 'updates an existing setting at the previous indentation regardless of indent_char and indent_width settings' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section:sub', setting: 'fleezy', value: 'flam2', indent_char: 'ignore this', indent_width: 10)) provider = described_class.new(resource) @@ -1359,7 +1359,7 @@ def self.file_path context 'when dealing settings that have a commented version present' do let(:orig_content) do - <<~EOS + <<~INIFILE [section1] # foo=foovalue bar=barvalue @@ -1370,10 +1370,10 @@ def self.file_path ;bar=barvalue blah = blah #baz= - EOS + INIFILE end - expected_content_eight = <<~EOS + expected_content_eight = <<~INIFILE [section1] # foo=foovalue bar=barvalue @@ -1385,7 +1385,7 @@ def self.file_path ;bar=barvalue blah = blah #baz= - EOS + INIFILE it 'adds a new setting below a commented version of that setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'foo', value: 'foo3')) provider = described_class.new(resource) @@ -1394,7 +1394,7 @@ def self.file_path validate_file(expected_content_eight, tmpfile) end - expected_content_nine = <<~EOS + expected_content_nine = <<~INIFILE [section1] # foo=foovalue bar=barvalue @@ -1405,7 +1405,7 @@ def self.file_path ;bar=barvalue blah = blah #baz= - EOS + INIFILE it 'updates an existing setting in place, even if there is a commented version of that setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section1', setting: 'foo', value: 'foo3')) provider = described_class.new(resource) @@ -1414,7 +1414,7 @@ def self.file_path validate_file(expected_content_nine, tmpfile) end - expected_content_ten = <<~EOS + expected_content_ten = <<~INIFILE [section1] # foo=foovalue bar=barvalue @@ -1426,7 +1426,7 @@ def self.file_path bar = bar3 blah = blah #baz= - EOS + INIFILE it 'adds a new setting below a commented version of that setting, respecting semicolons as comments' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'bar', value: 'bar3')) provider = described_class.new(resource) @@ -1435,7 +1435,7 @@ def self.file_path validate_file(expected_content_ten, tmpfile) end - expected_content_four = <<~EOS + expected_content_four = <<~INIFILE [section1] # foo=foovalue bar=barvalue @@ -1447,7 +1447,7 @@ def self.file_path blah = blah #baz= baz = bazvalue - EOS + INIFILE it 'adds a new setting below an empty commented version of that setting' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section2', setting: 'baz', value: 'bazvalue')) provider = described_class.new(resource) @@ -1458,19 +1458,19 @@ def self.file_path context 'when a section only contains comments' do let(:orig_content) do - <<~EOS + <<~INIFILE [section1] # foo=foovalue # bar=bar2 - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE [section1] # foo=foovalue foo = foovalue2 # bar=bar2 - EOS + INIFILE it 'is able to add a new setting when a section contains only comments' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section1', setting: 'foo', value: 'foovalue2')) provider = described_class.new(resource) @@ -1479,12 +1479,12 @@ def self.file_path validate_file(expected_content_one, tmpfile) end - expected_content_two = <<~EOS + expected_content_two = <<~INIFILE [section1] # foo=foovalue # bar=bar2 bar = barvalue2 - EOS + INIFILE it 'is able to add a new setting when it matches a commented out line other than the first one' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section1', setting: 'bar', value: 'barvalue2')) provider = described_class.new(resource) @@ -1496,7 +1496,7 @@ def self.file_path context 'when sections have spaces and dashes' do let(:orig_content) do - <<~EOS + <<~INIFILE # This is a comment [section - one] ; This is also a comment @@ -1513,10 +1513,10 @@ def self.file_path subby=bar #another comment ; yet another comment - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE # This is a comment [section - one] ; This is also a comment @@ -1534,7 +1534,7 @@ def self.file_path subby=bar #another comment ; yet another comment - EOS + INIFILE it 'adds a missing setting to the correct section' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'section - two', setting: 'yahoo', value: 'yippee')) provider = described_class.new(resource) @@ -1547,7 +1547,7 @@ def self.file_path context 'when sections have spaces and quotations' do let(:orig_content) do - <<~EOS + <<~INIFILE [branch "main"] remote = origin merge = refs/heads/main @@ -1557,10 +1557,10 @@ def self.file_path [branch "production"] remote = origin merge = refs/heads/production - EOS + INIFILE end - expected_content_one = <<~EOS + expected_content_one = <<~INIFILE [branch "main"] remote = origin merge = refs/heads/main @@ -1571,7 +1571,7 @@ def self.file_path [branch "production"] remote = origin merge = refs/heads/production - EOS + INIFILE it 'adds a missing setting to the correct section' do resource = Puppet::Type::Ini_setting.new(common_params.merge(section: 'alias', setting: 'foo', value: 'bar')) provider = described_class.new(resource) diff --git a/spec/unit/puppet/provider/ini_subsetting/ruby_spec.rb b/spec/unit/puppet/provider/ini_subsetting/ruby_spec.rb index 8596397e..9236fb68 100644 --- a/spec/unit/puppet/provider/ini_subsetting/ruby_spec.rb +++ b/spec/unit/puppet/provider/ini_subsetting/ruby_spec.rb @@ -29,14 +29,14 @@ def validate_file(expected_content, tmpfile) end let(:orig_content) do - <<-EOS + <<-JAVAARGS JAVA_ARGS="-Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof" - EOS + JAVAARGS end - expected_content_one = <<-EOS + expected_content_one = <<-JAVAARGS JAVA_ARGS="-Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof -Xms128m" - EOS + JAVAARGS it 'adds a missing subsetting' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-Xms', value: '128m')) provider = described_class.new(resource) @@ -45,9 +45,9 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_one, tmpfile) end - expected_content_two = <<-EOS + expected_content_two = <<-JAVAARGS JAVA_ARGS="-Xms128m -Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof" - EOS + JAVAARGS it 'adds a missing subsetting element at the beginning of the line' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-Xms', value: '128m', insert_type: :start)) provider = described_class.new(resource) @@ -56,9 +56,9 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_two, tmpfile) end - expected_content_three = <<-EOS + expected_content_three = <<-JAVAARGS JAVA_ARGS="-Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof -Xms128m" - EOS + JAVAARGS it 'adds a missing subsetting element at the end of the line' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-Xms', value: '128m', insert_type: :end)) provider = described_class.new(resource) @@ -67,9 +67,9 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_three, tmpfile) end - expected_content_four = <<-EOS + expected_content_four = <<-JAVAARGS JAVA_ARGS="-Xmx192m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof" - EOS + JAVAARGS it 'adds a missing subsetting element after the given item' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-Xms', value: '128m', insert_type: :after, insert_value: '-Xmx')) provider = described_class.new(resource) @@ -78,9 +78,9 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_four, tmpfile) end - expected_content_five = <<-EOS + expected_content_five = <<-JAVAARGS JAVA_ARGS="-Xms128m -Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof" - EOS + JAVAARGS it 'adds a missing subsetting element before the given item' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-Xms', value: '128m', insert_type: :before, insert_value: '-Xmx')) provider = described_class.new(resource) @@ -89,9 +89,9 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_five, tmpfile) end - expected_content_six = <<-EOS + expected_content_six = <<-JAVAARGS JAVA_ARGS="-Xmx192m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof" - EOS + JAVAARGS it 'adds a missing subsetting element at the given index' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-Xms', value: '128m', insert_type: :index, insert_value: '1')) provider = described_class.new(resource) @@ -100,9 +100,9 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_six, tmpfile) end - expected_content_seven = <<-EOS + expected_content_seven = <<-JAVAARGS JAVA_ARGS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof" - EOS + JAVAARGS it 'removes an existing subsetting' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-Xmx')) provider = described_class.new(resource) @@ -111,9 +111,9 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_seven, tmpfile) end - expected_content_eight = <<-EOS + expected_content_eight = <<-JAVAARGS JAVA_ARGS="-Xmx192m" - EOS + JAVAARGS it 'is able to remove several subsettings with the same name' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-XX')) provider = described_class.new(resource) @@ -122,9 +122,9 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_eight, tmpfile) end - expected_content_nine = <<-EOS + expected_content_nine = <<-JAVAARGS JAVA_ARGS="-Xmx256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof" - EOS + JAVAARGS it 'modifies an existing subsetting' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-Xmx', value: '256m')) provider = described_class.new(resource) @@ -133,9 +133,9 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_nine, tmpfile) end - expected_content_ten = <<-EOS + expected_content_ten = <<-JAVAARGS JAVA_ARGS="-Xmx192m -XXtest -XXtest" - EOS + JAVAARGS it 'is able to modify several subsettings with the same name' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: '-XX', value: 'test')) provider = described_class.new(resource) @@ -156,18 +156,18 @@ def validate_file(expected_content, tmpfile) end let(:orig_content) do - <<-EOS + <<-INIFILE [main] reports = http,foo - EOS + INIFILE end - expected_content_one = <<-EOS + expected_content_one = <<-INIFILE [main] reports = foo - EOS + INIFILE it 'removes an existing subsetting' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: 'http', subsetting_separator: ',')) provider = described_class.new(resource) @@ -176,11 +176,11 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_one, tmpfile) end - expected_content_two = <<-EOS + expected_content_two = <<-INIFILE [main] reports = http,foo,puppetdb - EOS + INIFILE it "adds a new subsetting when the 'parent' setting already exists" do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: 'puppetdb', subsetting_separator: ',')) provider = described_class.new(resource) @@ -189,12 +189,12 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_two, tmpfile) end - expected_content_three = <<-EOS + expected_content_three = <<-INIFILE [main] reports = http,foo somenewsetting = puppetdb - EOS + INIFILE it "adds a new subsetting when the 'parent' setting does not already exist" do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(setting: 'somenewsetting', subsetting: 'puppetdb', subsetting_separator: ',')) provider = described_class.new(resource) @@ -216,18 +216,18 @@ def validate_file(expected_content, tmpfile) end let(:orig_content) do - <<-EOS + <<-INIFILE [main] reports = http,foo - EOS + INIFILE end - expected_content_one = <<-EOS + expected_content_one = <<-INIFILE [main] reports = http,foo,fo - EOS + INIFILE it "adds a new subsetting when the 'parent' setting already exists" do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: 'fo', subsetting_separator: ',')) provider = described_class.new(resource) @@ -235,11 +235,11 @@ def validate_file(expected_content, tmpfile) expect(validate_file(expected_content_one, tmpfile)).to be_truthy end - expected_content_two = <<-EOS + expected_content_two = <<-INIFILE [main] reports = http,foo - EOS + INIFILE it 'does not remove substring subsettings' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: 'fo', subsetting_separator: ',')) provider = described_class.new(resource) @@ -262,18 +262,18 @@ def validate_file(expected_content, tmpfile) end let(:orig_content) do - <<-EOS + <<-INIFILE [main] reports = a:1,b:2 - EOS + INIFILE end - expected_content_one = <<-EOS + expected_content_one = <<-INIFILE [main] reports = a:1,b:2,c:3 - EOS + INIFILE it "adds a new subsetting when the 'parent' setting already exists" do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: 'c', value: '3')) provider = described_class.new(resource) @@ -281,12 +281,12 @@ def validate_file(expected_content, tmpfile) expect(validate_file(expected_content_one, tmpfile)).to be_truthy end - expected_content_two = <<-EOS + expected_content_two = <<-INIFILE [main] reports = a:1,b:2 somenewsetting = c:3 - EOS + INIFILE it "adds a new subsetting when the 'parent' setting does not already exist" do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: 'c', value: '3', setting: 'somenewsetting')) provider = described_class.new(resource) @@ -295,11 +295,11 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_two, tmpfile) end - expected_content_three = <<-EOS + expected_content_three = <<-INIFILE [main] reports = a:1 - EOS + INIFILE it 'is able to remove the existing subsetting' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: 'b')) provider = described_class.new(resource) @@ -308,11 +308,11 @@ def validate_file(expected_content, tmpfile) validate_file(expected_content_three, tmpfile) end - expected_content_four = <<-EOS + expected_content_four = <<-INIFILE [main] reports = a:1,b:5 - EOS + INIFILE it 'is able to modify the existing subsetting' do resource = Puppet::Type::Ini_subsetting.new(common_params.merge(subsetting: 'b', value: '5')) provider = described_class.new(resource) @@ -333,17 +333,17 @@ def validate_file(expected_content, tmpfile) end let(:orig_content) do - <<-EOS + <<-INIFILE [main] reports = http something = else - EOS + INIFILE end - expected_content_one = <<-EOS + expected_content_one = <<-INIFILE [main] something = else - EOS + INIFILE expected_content_two = '' diff --git a/spec/unit/puppet/util/ini_file_spec.rb b/spec/unit/puppet/util/ini_file_spec.rb index 4e51b090..05589644 100644 --- a/spec/unit/puppet/util/ini_file_spec.rb +++ b/spec/unit/puppet/util/ini_file_spec.rb @@ -16,7 +16,7 @@ context 'when parsing a file' do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE # This is a comment [section1] ; This is also a comment @@ -34,7 +34,7 @@ zot = multi word value xyzzy['thing1']['thing2']=xyzzyvalue l=git log - EOS + INIFILE template.split("\n") end @@ -65,11 +65,11 @@ context 'when parsing a file whose first line is a section' do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE [section1] ; This is a comment foo=foovalue - EOS + INIFILE template.split("\n") end @@ -90,12 +90,12 @@ context "when parsing a file with a 'global' section" do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE foo = bar [section1] ; This is a comment foo=foovalue - EOS + INIFILE template.split("\n") end @@ -120,12 +120,12 @@ context 'when updating a file with existing empty values' do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE [section1] foo= #bar= #xyzzy['thing1']['thing2']='xyzzyvalue' - EOS + INIFILE template.split("\n") end @@ -180,7 +180,7 @@ context 'when the file has quotation marks in its section names' do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE [branch "main"] remote = origin merge = refs/heads/main @@ -190,7 +190,7 @@ [branch "production"] remote = origin merge = refs/heads/production - EOS + INIFILE template.split("\n") end @@ -201,7 +201,7 @@ context 'when Samba INI file with dollars in section names' do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE [global] workgroup = FELLOWSHIP ; ... @@ -220,7 +220,7 @@ path = /home/shares read only = No guest ok = Yes - EOS + INIFILE template.split("\n") end @@ -231,10 +231,10 @@ context 'when section names with forward slashes in them' do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE [monitor:///var/log/*.log] disabled = test_value - EOS + INIFILE template.split("\n") end @@ -245,12 +245,12 @@ context 'when KDE Configuration with braces in setting names' do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE [khotkeys] _k_friendly_name=khotkeys {5465e8c7-d608-4493-a48f-b99d99fdb508}=Print,none,PrintScreen {d03619b6-9b3c-48cc-9d9c-a2aadb485550}=Search,none,Search - EOS + INIFILE template.split("\n") end @@ -265,12 +265,12 @@ context 'when Configuration with colons in setting names' do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE [Drive names] A:=5.25" Floppy B:=3.5" Floppy C:=Winchester - EOS + INIFILE template.split("\n") end @@ -289,7 +289,7 @@ context 'when Configuration with spaces in setting names' do let(:sample_content) do - template = <<-EOS + template = <<-INIFILE [global] # log files split per-machine: log file = /var/log/samba/log.%m @@ -297,7 +297,7 @@ kerberos method = system keytab passdb backend = tdbsam security = ads - EOS + INIFILE template.split("\n") end