diff --git a/.rubocop.yml b/.rubocop.yml index 53ac189..ea22bff 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,6 @@ --- +inherit_from: .rubocop_todo.yml + # Managed by modulesync - DO NOT EDIT # https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..3a62748 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,63 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-08-17 21:29:37 UTC using RuboCop version 1.50.2. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'lib/augeasproviders/mounttab/fstab.rb' + - 'lib/augeasproviders/mounttab/vfstab.rb' + +# Offense count: 67 +# Configuration parameters: CheckForMethodsWithNoSideEffects. +Lint/Void: + Exclude: + - 'spec/unit/puppet/provider/mounttab/fstab_spec.rb' + - 'spec/unit/puppet/provider/mounttab/vfstab_spec.rb' + +# Offense count: 4 +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Exclude: + - 'spec/unit/puppet/provider/mounttab/fstab_spec.rb' + - 'spec/unit/puppet/provider/mounttab/vfstab_spec.rb' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'lib/augeasproviders/mounttab/fstab.rb' + - 'lib/augeasproviders/mounttab/vfstab.rb' + - 'lib/puppet/provider/mounttab/augeas.rb' + +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'lib/augeasproviders.rb' + - 'lib/augeasproviders/mounttab.rb' + - 'lib/augeasproviders/mounttab/fstab.rb' + - 'lib/augeasproviders/mounttab/vfstab.rb' + - 'lib/puppet/provider/mounttab/augeas.rb' + - 'spec/unit/puppet/provider/mounttab/fstab_spec.rb' + - 'spec/unit/puppet/provider/mounttab/vfstab_spec.rb' + +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'lib/augeasproviders/mounttab.rb' + - 'lib/augeasproviders/mounttab/fstab.rb' + - 'lib/augeasproviders/mounttab/vfstab.rb' + - 'lib/puppet/provider/mounttab/augeas.rb' diff --git a/lib/augeasproviders/mounttab/fstab.rb b/lib/augeasproviders/mounttab/fstab.rb index 1fb6a19..1b26473 100644 --- a/lib/augeasproviders/mounttab/fstab.rb +++ b/lib/augeasproviders/mounttab/fstab.rb @@ -11,7 +11,6 @@ module AugeasProviders::Mounttab class Fstab - attr_reader :resource def self.default_file @@ -24,10 +23,11 @@ def self.lens def self.get_resource(aug, mpath, target) entry = { - :ensure => :present, - :target => target + ensure: :present, + target: target } return nil unless entry[:name] = aug.get("#{mpath}/file") + entry[:device] = aug.get("#{mpath}/spec") entry[:fstype] = aug.get("#{mpath}/vfstype") @@ -46,12 +46,12 @@ def self.get_resource(aug, mpath, target) end def self.create(aug, resource) - aug.set("$resource/spec", resource[:device]) - aug.set("$resource/file", resource[:name]) - aug.set("$resource/vfstype", resource[:fstype]) - insoptions(aug, "$resource", resource) - aug.set("$resource/dump", resource[:dump].to_s) - aug.set("$resource/passno", resource[:pass].to_s) + aug.set('$resource/spec', resource[:device]) + aug.set('$resource/file', resource[:name]) + aug.set('$resource/vfstype', resource[:fstype]) + insoptions(aug, '$resource', resource) + aug.set('$resource/dump', resource[:dump].to_s) + aug.set('$resource/passno', resource[:pass].to_s) end def self.insoptions(aug, entry, resource) @@ -60,20 +60,20 @@ def self.insoptions(aug, entry, resource) values = resource.original_parameters[:options] aug.rm("#{entry}/opt") - insafter = "vfstype" - if values and not values.empty? + insafter = 'vfstype' + if values and !values.empty? [values].flatten.each do |opt| - optk, optv = opt.split("=", 2) - aug.insert("#{entry}/#{insafter}", "opt", false) + optk, optv = opt.split('=', 2) + aug.insert("#{entry}/#{insafter}", 'opt', false) aug.set("#{entry}/opt[last()]", optk) aug.set("#{entry}/opt[last()]/value", optv) if optv - insafter = "opt[last()]" + insafter = 'opt[last()]' end else # Strictly this is optional, but only Augeas > 0.10.0 has a lens that # knows this is the case, so always fill it in. - aug.insert("#{entry}/#{insafter}", "opt", false) - aug.set("#{entry}/opt", "defaults") + aug.insert("#{entry}/#{insafter}", 'opt', false) + aug.set("#{entry}/opt", 'defaults') end end @@ -84,9 +84,7 @@ def self.dump(aug, resource) def self.set_dump(aug, resource, value) # Ensure "defaults" option is always set if dump is being set, as the # opts field is optional - if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty? - aug.set("$target/*[file = '#{resource[:name]}']/opt", "defaults") - end + aug.set("$target/*[file = '#{resource[:name]}']/opt", 'defaults') if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty? aug.set("$target/*[file = '#{resource[:name]}']/dump", value.to_s) end @@ -98,24 +96,20 @@ def self.pass(aug, resource) def self.set_pass(aug, resource, value) # Ensure "defaults" option is always set if passno is being set, as the # opts field is optional - if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty? - aug.set("$target/*[file = '#{resource[:name]}']/opt", "defaults") - end + aug.set("$target/*[file = '#{resource[:name]}']/opt", 'defaults') if aug.match("$target/*[file = '#{resource[:name]}']/opt").empty? # Ensure dump is always set too - if aug.match("$target/*[file = '#{resource[:name]}']/dump").empty? - aug.set("$target/*[file = '#{resource[:name]}']/dump", "0") - end + aug.set("$target/*[file = '#{resource[:name]}']/dump", '0') if aug.match("$target/*[file = '#{resource[:name]}']/dump").empty? aug.set("$target/*[file = '#{resource[:name]}']/passno", value.to_s) end - def self.atboot(aug, resource) + def self.atboot(_aug, resource) resource.should(:atboot) end - def self.set_atboot(aug, resource, value) - return + def self.set_atboot(_aug, _resource, _value) + nil end def self.empty_options diff --git a/lib/augeasproviders/mounttab/vfstab.rb b/lib/augeasproviders/mounttab/vfstab.rb index dffec68..b2ccdaa 100644 --- a/lib/augeasproviders/mounttab/vfstab.rb +++ b/lib/augeasproviders/mounttab/vfstab.rb @@ -11,7 +11,6 @@ module AugeasProviders::Mounttab class Vfstab - attr_reader :resource def self.default_file @@ -24,14 +23,15 @@ def self.lens def self.get_resource(aug, mpath, target) entry = { - :ensure => :present, - :target => target + ensure: :present, + target: target } return nil unless entry[:name] = aug.get("#{mpath}/file") + entry[:device] = aug.get("#{mpath}/spec") entry[:fstype] = aug.get("#{mpath}/vfstype") - entry[:blockdevice] = (aug.get("#{mpath}/fsck") or "-") - entry[:pass] = (aug.get("#{mpath}/passno") or "-") + entry[:blockdevice] = (aug.get("#{mpath}/fsck") or '-') + entry[:pass] = (aug.get("#{mpath}/passno") or '-') entry[:atboot] = aug.get("#{mpath}/atboot") options = [] @@ -42,24 +42,22 @@ def self.get_resource(aug, mpath, target) options << opt end entry[:options] = if options.empty? - "-" - else - options - end + '-' + else + options + end entry end def self.create(aug, resource) - aug.set("$resource/spec", resource[:device]) - if resource[:blockdevice] and resource[:blockdevice] != "" - aug.set("$resource/fsck", resource[:blockdevice]) - end - aug.set("$resource/file", resource[:name]) - aug.set("$resource/vfstype", resource[:fstype]) - aug.set("$resource/passno", resource[:pass].to_s) unless resource[:pass] == "-" - aug.set("$resource/atboot", resource[:atboot].to_s) - insoptions(aug, "$resource", resource) + aug.set('$resource/spec', resource[:device]) + aug.set('$resource/fsck', resource[:blockdevice]) if resource[:blockdevice] and resource[:blockdevice] != '' + aug.set('$resource/file', resource[:name]) + aug.set('$resource/vfstype', resource[:fstype]) + aug.set('$resource/passno', resource[:pass].to_s) unless resource[:pass] == '-' + aug.set('$resource/atboot', resource[:atboot].to_s) + insoptions(aug, '$resource', resource) end def target @@ -72,34 +70,32 @@ def self.insoptions(aug, entry, resource) values = resource.original_parameters[:options] aug.rm("#{entry}/opt") - if values and not values.empty? - [values].flatten.each do |opt| - optk, optv = opt.split("=", 2) - aug.set("#{entry}/opt[last()+1]", optk) - aug.set("#{entry}/opt[last()]/value", optv) if optv - end + return unless values and !values.empty? + + [values].flatten.each do |opt| + optk, optv = opt.split('=', 2) + aug.set("#{entry}/opt[last()+1]", optk) + aug.set("#{entry}/opt[last()]/value", optv) if optv end end - def self.dump(aug, resource) + def self.dump(_aug, resource) resource.should(:dump) end - def self.set_dump(aug, resource, value) - return + def self.set_dump(_aug, _resource, _value) + nil end def self.pass(aug, resource) - aug.get("$target/*[file = '#{resource[:name]}']/passno") or "-" + aug.get("$target/*[file = '#{resource[:name]}']/passno") or '-' end def self.set_pass(aug, resource, value) - if value == "-" + if value == '-' aug.rm("$target/*[file = '#{resource[:name]}']/passno") else - if aug.match("$target/*[file = '#{resource[:name]}']/passno").empty? - aug.insert("$target/*[file = '#{resource[:name]}']/vfstype", "passno", false) - end + aug.insert("$target/*[file = '#{resource[:name]}']/vfstype", 'passno', false) if aug.match("$target/*[file = '#{resource[:name]}']/passno").empty? aug.set("$target/*[file = '#{resource[:name]}']/passno", value.to_s) end end diff --git a/lib/puppet/provider/mounttab/augeas.rb b/lib/puppet/provider/mounttab/augeas.rb index d8a8021..91db2e5 100644 --- a/lib/puppet/provider/mounttab/augeas.rb +++ b/lib/puppet/provider/mounttab/augeas.rb @@ -13,14 +13,15 @@ require File.dirname(__FILE__) + '/../../../augeasproviders/mounttab/fstab' require File.dirname(__FILE__) + '/../../../augeasproviders/mounttab/vfstab' -raise("Missing augeasproviders_core dependency") if Puppet::Type.type(:augeasprovider).nil? -Puppet::Type.type(:mounttab).provide(:augeas, :parent => Puppet::Type.type(:augeasprovider).provider(:default)) do - desc "Uses Augeas API to update the /etc/(v)fstab file" +raise('Missing augeasproviders_core dependency') if Puppet::Type.type(:augeasprovider).nil? + +Puppet::Type.type(:mounttab).provide(:augeas, parent: Puppet::Type.type(:augeasprovider).provider(:default)) do + desc 'Uses Augeas API to update the /etc/(v)fstab file' def self.osimpl os = Facter.value(:osfamily) or Facter.value(:operatingsystem) case os - when "Solaris" + when 'Solaris' AugeasProviders::Mounttab::Vfstab else AugeasProviders::Mounttab::Fstab @@ -39,13 +40,13 @@ def self.osimpl "$target/*[file = '#{resource[:name]}']" end - confine :feature => :augeas - defaultfor :feature => :augeas + confine feature: :augeas + defaultfor feature: :augeas def self.instances augopen do |aug| resources = [] - aug.match("$target/*").each do |mpath| + aug.match('$target/*').each do |mpath| entry = osimpl.get_resource(aug, mpath, target) resources << new(entry) unless entry.nil? end @@ -53,7 +54,7 @@ def self.instances end end - def create + def create augopen! do |aug| aug.defnode('resource', "$target/#{next_seq(aug.match('$target/*'))}", nil) self.class.osimpl.create(aug, resource) @@ -74,18 +75,16 @@ def device=(value) def blockdevice augopen do |aug| - aug.get('$resource/fsck') or "-" + aug.get('$resource/fsck') or '-' end end def blockdevice=(value) augopen! do |aug| - if value == "-" + if value == '-' aug.rm('$resource/fsck') else - if aug.match('$resource/fsck').empty? - aug.insert('$resource/spec', 'fsck', false) - end + aug.insert('$resource/spec', 'fsck', false) if aug.match('$resource/fsck').empty? aug.set('$resource/fsck', value.to_s) end end @@ -112,7 +111,7 @@ def options opt = "#{opt}=#{optv}" if optv opts << opt end - opts = opts.join(",") + opts = opts.join(',') # [] and ["defaults"] are synonyms, so return what the user requested if # the current value is one of these to avoid changes @@ -129,7 +128,7 @@ def insoptions(aug, entry, resource) self.class.osimpl.insoptions(aug, entry, resource) end - def options=(values) + def options=(_values) augopen! do |aug| insoptions(aug, '$resource', resource) end diff --git a/spec/unit/puppet/provider/mounttab/fstab_spec.rb b/spec/unit/puppet/provider/mounttab/fstab_spec.rb index f03d721..2108a01 100755 --- a/spec/unit/puppet/provider/mounttab/fstab_spec.rb +++ b/spec/unit/puppet/provider/mounttab/fstab_spec.rb @@ -4,25 +4,26 @@ type = Puppet::Type.type(:mounttab) unless type - raise Puppet::DevError, < "/mnt", - :device => "/dev/myvg/mytest", - :fstype => "ext4", - :options => "defaults", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/spec").should == "/dev/myvg/mytest" - aug.get("./1/file").should == "/mnt" - aug.get("./1/vfstype").should == "ext4" - aug.match("./1/opt").size.should == 1 - aug.get("./1/opt[1]").should == "defaults" + name: '/mnt', + device: '/dev/myvg/mytest', + fstype: 'ext4', + options: 'defaults', + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./1/spec').should == '/dev/myvg/mytest' + aug.get('./1/file').should == '/mnt' + aug.get('./1/vfstype').should == 'ext4' + aug.match('./1/opt').size.should == 1 + aug.get('./1/opt[1]').should == 'defaults' end end - it "should create new entry" do + it 'creates new entry' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/mnt", - :device => "/dev/myvg/mytest", - :fstype => "ext4", - :options => [ "nosuid", "uid=12345" ], - :dump => "1", - :pass => "2", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/spec").should == "/dev/myvg/mytest" - aug.get("./1/file").should == "/mnt" - aug.get("./1/vfstype").should == "ext4" - aug.match("./1/opt").size.should == 2 - aug.get("./1/opt[1]").should == "nosuid" - aug.get("./1/opt[2]").should == "uid" - aug.get("./1/opt[2]/value").should == "12345" - aug.get("./1/dump").should == "1" - aug.get("./1/passno").should == "2" + name: '/mnt', + device: '/dev/myvg/mytest', + fstype: 'ext4', + options: ['nosuid', 'uid=12345'], + dump: '1', + pass: '2', + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./1/spec').should == '/dev/myvg/mytest' + aug.get('./1/file').should == '/mnt' + aug.get('./1/vfstype').should == 'ext4' + aug.match('./1/opt').size.should == 2 + aug.get('./1/opt[1]').should == 'nosuid' + aug.get('./1/opt[2]').should == 'uid' + aug.get('./1/opt[2]/value').should == '12345' + aug.get('./1/dump').should == '1' + aug.get('./1/passno').should == '2' end end - it "should create new entry without options" do + it 'creates new entry without options' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/mnt", - :device => "/dev/myvg/mytest", - :fstype => "ext4", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/spec").should == "/dev/myvg/mytest" - aug.get("./1/file").should == "/mnt" - aug.get("./1/vfstype").should == "ext4" - aug.match("./1/opt").size.should == 1 - aug.get("./1/opt[1]").should == "defaults" + name: '/mnt', + device: '/dev/myvg/mytest', + fstype: 'ext4', + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./1/spec').should == '/dev/myvg/mytest' + aug.get('./1/file').should == '/mnt' + aug.get('./1/vfstype').should == 'ext4' + aug.match('./1/opt').size.should == 1 + aug.get('./1/opt[1]').should == 'defaults' end end - it "should create two new entries" do + it 'creates two new entries' do apply!( Puppet::Type.type(:mounttab).new( - :name => "/mnt", - :device => "/dev/myvg/mytest", - :fstype => "ext4", - :target => target, - :provider => "augeas" + name: '/mnt', + device: '/dev/myvg/mytest', + fstype: 'ext4', + target: target, + provider: 'augeas' ), Puppet::Type.type(:mounttab).new( - :name => "/mnt2", - :device => "/dev/myvg/mysecond", - :fstype => "ext4", - :target => target, - :provider => "augeas" + name: '/mnt2', + device: '/dev/myvg/mysecond', + fstype: 'ext4', + target: target, + provider: 'augeas' ) ) - aug_open(target, "Fstab.lns") do |aug| + aug_open(target, 'Fstab.lns') do |aug| aug.match("./*[vfstype='ext4']").size.should == 2 end end end - context "with full file" do - let(:tmptarget) { aug_fixture("full") } + context 'with full file' do + let(:tmptarget) { aug_fixture('full') } let(:target) { tmptarget.path } - it "should list instances" do + it 'lists instances' do allow(provider_class).to receive(:target).and_return(target) - inst = provider_class.instances.map { |p| + inst = provider_class.instances.map do |p| r = {} - [:name,:ensure,:device,:blockdevice,:fstype,:options,:pass,:atboot,:dump].each { |pr| r[pr] = p.get(pr) } + %i[name ensure device blockdevice fstype options pass atboot dump].each { |pr| r[pr] = p.get(pr) } r - } + end inst.size.should == 8 - inst[0].should == {:name=>"/", :ensure=>:present, :device=>"/dev/mapper/vgiridium-lvroot", :blockdevice=>:absent, :fstype=>"ext4", :options=>["noatime"], :pass=>:absent, :atboot=>:absent, :dump=>:absent} - inst[1].should == {:name=>"/boot", :ensure=>:present, :device=>"UUID=23b3b5f4-d5b3-4661-ad41-caa970f3ca59", :blockdevice=>:absent, :fstype=>"ext4", :options=>["noatime"], :pass=>"2", :atboot=>:absent, :dump=>"1"} - inst[2].should == {:name=>"/home", :ensure=>:present, :device=>"/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1", :blockdevice=>:absent, :fstype=>"ext4", :options=>["noatime"], :pass=>"2", :atboot=>:absent, :dump=>"1"} - inst[3].should == {:name=>"/tmp", :ensure=>:present, :device=>"tmpfs", :blockdevice=>:absent, :fstype=>"tmpfs", :options=>["size=1024m"], :pass=>"0", :atboot=>:absent, :dump=>"0"} + inst[0].should == { name: '/', ensure: :present, device: '/dev/mapper/vgiridium-lvroot', blockdevice: :absent, fstype: 'ext4', options: ['noatime'], pass: :absent, atboot: :absent, dump: :absent } + inst[1].should == { name: '/boot', ensure: :present, device: 'UUID=23b3b5f4-d5b3-4661-ad41-caa970f3ca59', blockdevice: :absent, fstype: 'ext4', options: ['noatime'], pass: '2', atboot: :absent, dump: '1' } + inst[2].should == { name: '/home', ensure: :present, device: '/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1', blockdevice: :absent, fstype: 'ext4', options: ['noatime'], pass: '2', atboot: :absent, dump: '1' } + inst[3].should == { name: '/tmp', ensure: :present, device: 'tmpfs', blockdevice: :absent, fstype: 'tmpfs', options: ['size=1024m'], pass: '0', atboot: :absent, dump: '0' } end - it "should delete entries" do - aug_open(target, "Fstab.lns") do |aug| + it 'deletes entries' do + aug_open(target, 'Fstab.lns') do |aug| aug.match("*[file = '/']").should_not == [] end apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) + name: '/', + ensure: 'absent', + target: target, + provider: 'augeas' + )) - aug_open(target, "Fstab.lns") do |aug| + aug_open(target, 'Fstab.lns') do |aug| aug.match("*[file = '/']").should == [] end end - it "should update device" do + it 'updates device' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :device => "/dev/myvg/mytest", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/spec").should == "/dev/myvg/mytest" - - aug.get("./3/vfstype").should == "ext4" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "noatime" + name: '/home', + device: '/dev/myvg/mytest', + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.get('./3/spec').should == '/dev/myvg/mytest' + + aug.get('./3/vfstype').should == 'ext4' + aug.match('./3/opt').size.should == 1 + aug.get('./3/opt[1]').should == 'noatime' end end - it "should update device without changing dump or pass" do + it 'updates device without changing dump or pass' do pending "issue #16122 against mounttab type as they're changing" apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :device => "/dev/myvg/mytest", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/spec").should == "/dev/myvg/mytest" - aug.get("./3/dump").should == "1" - aug.get("./3/passno").should == "2" + name: '/home', + device: '/dev/myvg/mytest', + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.get('./3/spec').should == '/dev/myvg/mytest' + aug.get('./3/dump').should == '1' + aug.get('./3/passno').should == '2' end end - it "should update fstype" do + it 'updates fstype' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :fstype => "btrfs", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/vfstype").should == "btrfs" - - aug.get("./3/spec").should == "/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "noatime" + name: '/home', + fstype: 'btrfs', + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.get('./3/vfstype').should == 'btrfs' + + aug.get('./3/spec').should == '/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1' + aug.match('./3/opt').size.should == 1 + aug.get('./3/opt[1]').should == 'noatime' end end - describe "when updating options" do - it "should replace with one option" do + describe 'when updating options' do + it 'replaces with one option' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :options => "nosuid", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "nosuid" - - aug.get("./3/spec").should == "/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1" - aug.get("./3/vfstype").should == "ext4" + name: '/home', + options: 'nosuid', + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.match('./3/opt').size.should == 1 + aug.get('./3/opt[1]').should == 'nosuid' + + aug.get('./3/spec').should == '/dev/mapper/luks-10f63ee4-8296-434e-8de1-cde932e8a2e1' + aug.get('./3/vfstype').should == 'ext4' end end - it "should add multiple options" do + it 'adds multiple options' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :options => ["nosuid", "nodev"], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 2 - aug.get("./3/opt[1]").should == "nosuid" - aug.get("./3/opt[2]").should == "nodev" + name: '/home', + options: %w[nosuid nodev], + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.match('./3/opt').size.should == 2 + aug.get('./3/opt[1]').should == 'nosuid' + aug.get('./3/opt[2]').should == 'nodev' end end - it "should add various complex options" do + it 'adds various complex options' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :options => ["nosuid", "uid=12345", 'rootcontext="system_u:object_r:tmpfs_t:s0"'], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 3 - aug.get("./3/opt[1]").should == "nosuid" - aug.get("./3/opt[2]").should == "uid" - aug.get("./3/opt[2]/value").should == "12345" - aug.get("./3/opt[3]").should == "rootcontext" - aug.get("./3/opt[3]/value").should == '"system_u:object_r:tmpfs_t:s0"' + name: '/home', + options: ['nosuid', 'uid=12345', 'rootcontext="system_u:object_r:tmpfs_t:s0"'], + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.match('./3/opt').size.should == 3 + aug.get('./3/opt[1]').should == 'nosuid' + aug.get('./3/opt[2]').should == 'uid' + aug.get('./3/opt[2]/value').should == '12345' + aug.get('./3/opt[3]').should == 'rootcontext' + aug.get('./3/opt[3]/value').should == '"system_u:object_r:tmpfs_t:s0"' end end - it "should remove options" do + it 'removes options' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :options => [], - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "defaults" + name: '/home', + options: [], + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.match('./3/opt').size.should == 1 + aug.get('./3/opt[1]').should == 'defaults' end end - it "should leave options alone" do + it 'leaves options alone' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.match("./3/opt").size.should == 1 - aug.get("./3/opt[1]").should == "noatime" + name: '/home', + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.match('./3/opt').size.should == 1 + aug.get('./3/opt[1]').should == 'noatime' end end end - describe "when updating dump" do - it "should add dump" do + describe 'when updating dump' do + it 'adds dump' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :dump => 1, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/file").should == "/" - aug.get("./1/dump").should == "1" + name: '/', + dump: 1, + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./1/file').should == '/' + aug.get('./1/dump').should == '1' end end - context "when nooptions is supported", :if => nooptions_supported? do - let(:tmptarget) { aug_fixture("nooptions") } + context 'when nooptions is supported', if: nooptions_supported? do + let(:tmptarget) { aug_fixture('nooptions') } let(:target) { tmptarget.path } - it "should add options first, then dump" do + it 'adds options first, then dump' do apply!(Puppet::Type.type(:mounttab).new( - :name => "swap", - :dump => 1, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./5/file").should == "swap" - aug.match("./5/opt").size.should == 1 - aug.get("./5/opt[1]").should == "defaults" - aug.get("./5/dump").should == "1" + name: 'swap', + dump: 1, + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./5/file').should == 'swap' + aug.match('./5/opt').size.should == 1 + aug.get('./5/opt[1]').should == 'defaults' + aug.get('./5/dump').should == '1' end end end - it "should change dump" do + it 'changes dump' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :dump => 0, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/dump").should == "0" + name: '/home', + dump: 0, + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.get('./3/dump').should == '0' end end end - describe "when updating pass" do - it "should add dump and pass" do + describe 'when updating pass' do + it 'adds dump and pass' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :pass => 2, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./1/file").should == "/" + name: '/', + pass: 2, + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./1/file').should == '/' # dump will be missing, so it also has to be added - aug.get("./1/dump").should == "0" - aug.get("./1/passno").should == "2" + aug.get('./1/dump').should == '0' + aug.get('./1/passno').should == '2' end end - context "when nooptions is supported", :if => nooptions_supported? do - let(:tmptarget) { aug_fixture("nooptions") } + context 'when nooptions is supported', if: nooptions_supported? do + let(:tmptarget) { aug_fixture('nooptions') } let(:target) { tmptarget.path } - it "should add options and dump first, then pass" do + it 'adds options and dump first, then pass' do apply!(Puppet::Type.type(:mounttab).new( - :name => "swap", - :pass => 1, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./5/file").should == "swap" - aug.match("./5/opt").size.should == 1 - aug.get("./5/opt[1]").should == "defaults" - aug.get("./5/dump").should == "0" - aug.get("./5/passno").should == "1" + name: 'swap', + pass: 1, + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./5/file').should == 'swap' + aug.match('./5/opt').size.should == 1 + aug.get('./5/opt[1]').should == 'defaults' + aug.get('./5/dump').should == '0' + aug.get('./5/passno').should == '1' end end end - it "should change pass" do + it 'changes pass' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/home", - :pass => 1, - :target => target, - :provider => "augeas" - )) - - aug_open(target, "Fstab.lns") do |aug| - aug.get("./3/file").should == "/home" - aug.get("./3/passno").should == "1" + name: '/home', + pass: 1, + target: target, + provider: 'augeas' + )) + + aug_open(target, 'Fstab.lns') do |aug| + aug.get('./3/file').should == '/home' + aug.get('./3/passno').should == '1' end end end end - context "with broken file" do - let(:tmptarget) { aug_fixture("broken") } + context 'with broken file' do + let(:tmptarget) { aug_fixture('broken') } let(:target) { tmptarget.path } - it "should fail to load" do + it 'fails to load' do txn = apply(Puppet::Type.type(:mounttab).new( - :name => "/home", - :device => "LABEL=home", - :target => target, - :provider => "augeas" - )) + name: '/home', + device: 'LABEL=home', + target: target, + provider: 'augeas' + )) - txn.any_failed?.should_not == nil + txn.any_failed?.should_not.nil? @logs.first.level.should == :err @logs.first.message.include?(target).should == true end diff --git a/spec/unit/puppet/provider/mounttab/vfstab_spec.rb b/spec/unit/puppet/provider/mounttab/vfstab_spec.rb old mode 100644 new mode 100755 index aa74419..6fd11f6 --- a/spec/unit/puppet/provider/mounttab/vfstab_spec.rb +++ b/spec/unit/puppet/provider/mounttab/vfstab_spec.rb @@ -8,33 +8,33 @@ def valid_lens? Puppet::Util::Package.versioncmp(Puppet::Type.type(:mounttab).provider(:augeas).aug_version, '0.10.0') > 0 end -describe provider_class, :if => valid_lens? do - before :each do +describe provider_class, if: valid_lens? do + before do allow(Facter).to receive(:value).with(:hostname).and_return('localhost') allow(Facter).to receive(:value).with(:domain).and_return('localdomain') allow(Facter).to receive(:value).with(:feature).and_return(nil) - allow(Facter).to receive(:value).with(:osfamily).and_return("Solaris") - allow(Facter).to receive(:value).with(:operatingsystem).and_return("Solaris") + allow(Facter).to receive(:value).with(:osfamily).and_return('Solaris') + allow(Facter).to receive(:value).with(:operatingsystem).and_return('Solaris') allow(FileTest).to receive(:exist?).and_return false allow(FileTest).to receive(:exist?).with('/etc/fstab').and_return true allow(FileTest).to receive(:exist?).with('/etc/vfstab').and_return true end - context "with empty vfstab file" do - let(:tmptarget) { aug_fixture("empty") } + context 'with empty vfstab file' do + let(:tmptarget) { aug_fixture('empty') } let(:target) { tmptarget.path } - it "should create simple new entry" do + it 'creates simple new entry' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/foo", - :device => "/dev/dsk/c1t1d1s1", - :fstype => "ufs", - :atboot => "yes", - :target => target, - :provider => "augeas" - )) - - augparse(target, "Vfstab.lns", ' + name: '/foo', + device: '/dev/dsk/c1t1d1s1', + fstype: 'ufs', + atboot: 'yes', + target: target, + provider: 'augeas' + )) + + augparse(target, 'Vfstab.lns', ' { "1" { "spec" = "/dev/dsk/c1t1d1s1" } { "fsck" = "/dev/rdsk/c1t1d1s1" } @@ -45,20 +45,20 @@ def valid_lens? ') end - it "should create new entry" do + it 'creates new entry' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/foo", - :device => "/dev/dsk/c1t1d1s1", - :blockdevice => "/dev/foo/c1t1d1s1", - :fstype => "ufs", - :pass => "2", - :atboot => "yes", - :options => [ "nosuid", "nodev" ], - :target => target, - :provider => "augeas" - )) - - augparse(target, "Vfstab.lns", ' + name: '/foo', + device: '/dev/dsk/c1t1d1s1', + blockdevice: '/dev/foo/c1t1d1s1', + fstype: 'ufs', + pass: '2', + atboot: 'yes', + options: %w[nosuid nodev], + target: target, + provider: 'augeas' + )) + + augparse(target, 'Vfstab.lns', ' { "1" { "spec" = "/dev/dsk/c1t1d1s1" } { "fsck" = "/dev/foo/c1t1d1s1" } @@ -72,87 +72,87 @@ def valid_lens? ') end - it "should create two new entries" do + it 'creates two new entries' do apply!( Puppet::Type.type(:mounttab).new( - :name => "/foo", - :device => "/dev/dsk/c1t1d1s1", - :blockdevice => "/dev/foo/c1t1d1s1", - :fstype => "ufs", - :pass => "2", - :atboot => "yes", - :options => [ "nosuid", "nodev" ], - :target => target, - :provider => "augeas" + name: '/foo', + device: '/dev/dsk/c1t1d1s1', + blockdevice: '/dev/foo/c1t1d1s1', + fstype: 'ufs', + pass: '2', + atboot: 'yes', + options: %w[nosuid nodev], + target: target, + provider: 'augeas' ), Puppet::Type.type(:mounttab).new( - :name => "/bar", - :device => "/dev/dsk/c1t1d2s1", - :blockdevice => "/dev/foo/c1t1d2s1", - :fstype => "ufs", - :pass => "2", - :atboot => "yes", - :options => [ "nosuid", "nodev" ], - :target => target, - :provider => "augeas" + name: '/bar', + device: '/dev/dsk/c1t1d2s1', + blockdevice: '/dev/foo/c1t1d2s1', + fstype: 'ufs', + pass: '2', + atboot: 'yes', + options: %w[nosuid nodev], + target: target, + provider: 'augeas' ) ) - aug_open(target, "Vfstab.lns") do |aug| + aug_open(target, 'Vfstab.lns') do |aug| aug.match("./*[vfstype='ufs']").size.should == 2 end end end - context "with full vfstab file" do - let(:tmptarget) { aug_fixture("full") } + context 'with full vfstab file' do + let(:tmptarget) { aug_fixture('full') } let(:target) { tmptarget.path } - it "should list instances" do + it 'lists instances' do allow(provider_class).to receive(:target).and_return(target) - inst = provider_class.instances.map { |p| + inst = provider_class.instances.map do |p| r = {} - [:name,:ensure,:device,:blockdevice,:fstype,:options,:pass,:atboot,:dump].each { |pr| r[pr] = p.get(pr) } + %i[name ensure device blockdevice fstype options pass atboot dump].each { |pr| r[pr] = p.get(pr) } r - } + end inst.size.should == 6 - inst[0].should == {:name=>"/dev/fd", :ensure=>:present, :device=>"fd", :blockdevice=>"-", :fstype=>"fd", :options=>"-", :pass=>"-", :atboot=>"no", :dump=>:absent} - inst[1].should == {:name=>"/proc", :ensure=>:present, :device=>"/proc", :blockdevice=>"-", :fstype=>"proc", :options=>"-", :pass=>"-", :atboot=>"no", :dump=>:absent} - inst[2].should == {:name=>"-", :ensure=>:present, :device=>"/dev/dsk/c0t0d0s1", :blockdevice=>"-", :fstype=>"swap", :options=>"-", :pass=>"-", :atboot=>"no", :dump=>:absent} - inst[3].should == {:name=>"/", :ensure=>:present, :device=>"/dev/dsk/c0t0d0s0", :blockdevice=>"/dev/rdsk/c0t0d0s0", :fstype=>"ufs", :options=>"-", :pass=>"1", :atboot=>"no", :dump=>:absent} - inst[5].should == {:name=>"/tmp", :ensure=>:present, :device=>"swap", :blockdevice=>"-", :fstype=>"tmpfs", :options=>["size=1024m"], :pass=>"-", :atboot=>"yes", :dump=>:absent} + inst[0].should == { name: '/dev/fd', ensure: :present, device: 'fd', blockdevice: '-', fstype: 'fd', options: '-', pass: '-', atboot: 'no', dump: :absent } + inst[1].should == { name: '/proc', ensure: :present, device: '/proc', blockdevice: '-', fstype: 'proc', options: '-', pass: '-', atboot: 'no', dump: :absent } + inst[2].should == { name: '-', ensure: :present, device: '/dev/dsk/c0t0d0s1', blockdevice: '-', fstype: 'swap', options: '-', pass: '-', atboot: 'no', dump: :absent } + inst[3].should == { name: '/', ensure: :present, device: '/dev/dsk/c0t0d0s0', blockdevice: '/dev/rdsk/c0t0d0s0', fstype: 'ufs', options: '-', pass: '1', atboot: 'no', dump: :absent } + inst[5].should == { name: '/tmp', ensure: :present, device: 'swap', blockdevice: '-', fstype: 'tmpfs', options: ['size=1024m'], pass: '-', atboot: 'yes', dump: :absent } end - it "should delete entries" do - aug_open(target, "Vfstab.lns") do |aug| + it 'deletes entries' do + aug_open(target, 'Vfstab.lns') do |aug| aug.match("*[file = '/']").should_not == [] end apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :ensure => "absent", - :target => target, - :provider => "augeas" - )) + name: '/', + ensure: 'absent', + target: target, + provider: 'augeas' + )) - aug_open(target, "Vfstab.lns") do |aug| + aug_open(target, 'Vfstab.lns') do |aug| aug.match("*[file = '/']").should == [] end end - it "should update device" do + it 'updates device' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :device => "/dev/dsk/c1t1d1s1", - :target => target, - :provider => "augeas" - )) + name: '/', + device: '/dev/dsk/c1t1d1s1', + target: target, + provider: 'augeas' + )) # fsck will get updated implicitly, due to the type # passno gets removed due to issue #16122 against mounttab # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/']", ' { "1" { "spec" = "/dev/dsk/c1t1d1s1" } { "fsck" = "/dev/rdsk/c1t1d1s1" } @@ -163,17 +163,17 @@ def valid_lens? ') end - it "should update fstype" do + it 'updates fstype' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :fstype => "zfs", - :target => target, - :provider => "augeas" - )) + name: '/', + fstype: 'zfs', + target: target, + provider: 'augeas' + )) # passno gets removed due to issue #16122 against mounttab # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/']", ' { "1" { "spec" = "/dev/dsk/c0t0d0s0" } { "fsck" = "/dev/rdsk/c0t0d0s0" } @@ -184,16 +184,16 @@ def valid_lens? ') end - describe "when updating options" do - it "should replace with one option" do + describe 'when updating options' do + it 'replaces with one option' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :options => "nosuid", - :target => target, - :provider => "augeas" - )) + name: '/tmp', + options: 'nosuid', + target: target, + provider: 'augeas' + )) - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/tmp']", ' { "1" { "spec" = "swap" } { "file" = "/tmp" } @@ -204,15 +204,15 @@ def valid_lens? ') end - it "should add multiple options" do + it 'adds multiple options' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :options => ["nosuid", "nodev"], - :target => target, - :provider => "augeas" - )) + name: '/tmp', + options: %w[nosuid nodev], + target: target, + provider: 'augeas' + )) - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/tmp']", ' { "1" { "spec" = "swap" } { "file" = "/tmp" } @@ -224,15 +224,15 @@ def valid_lens? ') end - it "should remove options" do + it 'removes options' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :options => [], - :target => target, - :provider => "augeas" - )) + name: '/tmp', + options: [], + target: target, + provider: 'augeas' + )) - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/tmp']", ' { "1" { "spec" = "swap" } { "file" = "/tmp" } @@ -242,16 +242,16 @@ def valid_lens? ') end - it "should leave options alone" do + it 'leaves options alone' do pending "issue #16122 against mounttab type as they're being removed" apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :target => target, - :provider => "augeas" - )) + name: '/tmp', + target: target, + provider: 'augeas' + )) - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/tmp']", ' { "1" { "spec" = "swap" } { "file" = "/tmp" } @@ -264,16 +264,16 @@ def valid_lens? end end - describe "when updating blockdevice" do - it "should add blockdevice" do + describe 'when updating blockdevice' do + it 'adds blockdevice' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/tmp", - :blockdevice => "/dev/tofsck", - :target => target, - :provider => "augeas" - )) + name: '/tmp', + blockdevice: '/dev/tofsck', + target: target, + provider: 'augeas' + )) - augparse_filter(target, "Vfstab.lns", "*[file='/tmp']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/tmp']", ' { "1" { "spec" = "swap" } { "fsck" = "/dev/tofsck" } @@ -284,17 +284,17 @@ def valid_lens? ') end - it "should change blockdevice" do + it 'changes blockdevice' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :blockdevice => "/dev/foo/c0t0d0s0", - :target => target, - :provider => "augeas" - )) + name: '/', + blockdevice: '/dev/foo/c0t0d0s0', + target: target, + provider: 'augeas' + )) # passno gets removed due to issue #16122 against mounttab # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/']", ' { "1" { "spec" = "/dev/dsk/c0t0d0s0" } { "fsck" = "/dev/foo/c0t0d0s0" } @@ -305,17 +305,17 @@ def valid_lens? ') end - it "should remove blockdevice" do + it 'removes blockdevice' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/fsck", - :blockdevice => "-", - :target => target, - :provider => "augeas" - )) + name: '/fsck', + blockdevice: '-', + target: target, + provider: 'augeas' + )) # passno gets removed due to issue #16122 against mounttab # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/fsck']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/fsck']", ' { "1" { "spec" = "mydev" } { "file" = "/fsck" } @@ -326,16 +326,16 @@ def valid_lens? end end - describe "when updating atboot" do - it "should change atboot" do + describe 'when updating atboot' do + it 'changes atboot' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/dev/fd", - :atboot => "yes", - :target => target, - :provider => "augeas" - )) + name: '/dev/fd', + atboot: 'yes', + target: target, + provider: 'augeas' + )) - augparse_filter(target, "Vfstab.lns", "*[file='/dev/fd']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/dev/fd']", ' { "1" { "spec" = "fd" } { "file" = "/dev/fd" } @@ -346,17 +346,17 @@ def valid_lens? end end - describe "when updating pass" do - it "should add pass" do + describe 'when updating pass' do + it 'adds pass' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/dev/fd", - :pass => 2, - :target => target, - :provider => "augeas" - )) + name: '/dev/fd', + pass: 2, + target: target, + provider: 'augeas' + )) # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/dev/fd']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/dev/fd']", ' { "1" { "spec" = "fd" } { "file" = "/dev/fd" } @@ -367,16 +367,16 @@ def valid_lens? ') end - it "should change pass" do + it 'changes pass' do apply!(Puppet::Type.type(:mounttab).new( - :name => "/", - :pass => 7, - :target => target, - :provider => "augeas" - )) + name: '/', + pass: 7, + target: target, + provider: 'augeas' + )) # atboot will get changed, also #16122 - augparse_filter(target, "Vfstab.lns", "*[file='/']", ' + augparse_filter(target, 'Vfstab.lns', "*[file='/']", ' { "1" { "spec" = "/dev/dsk/c0t0d0s0" } { "fsck" = "/dev/rdsk/c0t0d0s0" } @@ -390,19 +390,19 @@ def valid_lens? end end - context "with broken vfstab file" do - let(:tmptarget) { aug_fixture("broken") } + context 'with broken vfstab file' do + let(:tmptarget) { aug_fixture('broken') } let(:target) { tmptarget.path } - it "should fail to load" do + it 'fails to load' do txn = apply(Puppet::Type.type(:mounttab).new( - :name => "/", - :device => "/dev/dsk/c0t0d1s0", - :target => target, - :provider => "augeas" - )) + name: '/', + device: '/dev/dsk/c0t0d1s0', + target: target, + provider: 'augeas' + )) - txn.any_failed?.should_not == nil + txn.any_failed?.should_not.nil? @logs.first.level.should == :err @logs.first.message.include?(target).should == true end