diff --git a/.gitignore b/.gitignore index 3f0816c09..3272a98e7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /Gemfile.local /.bundle/ /vendor/ +/.vendor/ .ruby-version /tmp/ /spec/fixtures/modules/augeas_core/ diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e9822e6d9..1e269f9de 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-01-22 15:56:59 UTC using RuboCop version 1.50.2. +# on 2024-10-25 12:07:22 UTC using RuboCop version 1.67.0. # 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 @@ -26,11 +26,17 @@ Lint/EmptyBlock: - 'spec/unit/adapters_spec.rb' # Offense count: 3 +# Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Exclude: - 'lib/rspec-puppet/errors.rb' - 'lib/rspec-puppet/sensitive.rb' +# Offense count: 1 +Lint/MixedRegexpCaptureTypes: + Exclude: + - 'Gemfile' + # Offense count: 1 Lint/RescueException: Exclude: @@ -50,64 +56,11 @@ Lint/SuppressedException: # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. +# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. Lint/UnusedMethodArgument: Exclude: - 'lib/rspec-puppet/support.rb' -# Offense count: 5 -Lint/UselessAssignment: - Exclude: - - 'lib/rspec-puppet/example/function_example_group.rb' - - 'lib/rspec-puppet/matchers/create_generic.rb' - - 'lib/rspec-puppet/monkey_patches.rb' - -# Offense count: 27 -# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. -Metrics/AbcSize: - Max: 59 - -# Offense count: 7 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. -# AllowedMethods: refine -Metrics/BlockLength: - Max: 111 - -# Offense count: 1 -# Configuration parameters: CountBlocks. -Metrics/BlockNesting: - Max: 4 - -# Offense count: 6 -# Configuration parameters: CountComments, CountAsOne. -Metrics/ClassLength: - Max: 297 - -# Offense count: 18 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Metrics/CyclomaticComplexity: - Max: 18 - -# Offense count: 47 -# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. -Metrics/MethodLength: - Max: 53 - -# Offense count: 2 -# Configuration parameters: CountComments, CountAsOne. -Metrics/ModuleLength: - Max: 383 - -# Offense count: 2 -# Configuration parameters: CountKeywordArgs, MaxOptionalParameters. -Metrics/ParameterLists: - Max: 9 - -# Offense count: 13 -# Configuration parameters: AllowedMethods, AllowedPatterns. -Metrics/PerceivedComplexity: - Max: 20 - # Offense count: 2 Naming/AccessorMethodName: Exclude: @@ -125,6 +78,7 @@ Naming/ConstantName: # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Naming/FileName: Exclude: + - 'Rakefile.rb' - 'lib/rspec-puppet.rb' - 'spec/functions/camelCaseFunction_spec.rb' @@ -138,6 +92,7 @@ Naming/HeredocDelimiterNaming: - 'spec/unit/matchers/compile_spec.rb' # Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyleForLeadingUnderscores. # SupportedStylesForLeadingUnderscores: disallowed, required, optional Naming/MemoizedInstanceVariableName: @@ -232,7 +187,7 @@ RSpec/MultipleDescribes: - 'spec/unit/example/function_example_group_spec.rb' - 'spec/unit/monkey_patches_spec.rb' -# Offense count: 45 +# Offense count: 49 RSpec/MultipleExpectations: Max: 8 @@ -241,7 +196,7 @@ RSpec/MultipleExpectations: RSpec/MultipleMemoizedHelpers: Max: 7 -# Offense count: 263 +# Offense count: 274 # Configuration parameters: EnforcedStyle, IgnoreSharedExamples. # SupportedStyles: always, named_only RSpec/NamedSubject: @@ -323,6 +278,12 @@ RSpec/VerifiedDoubles: - 'spec/unit/matchers/allow_value_spec.rb' - 'spec/unit/sensitive_spec.rb' +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Rake/Desc: + Exclude: + - 'Rakefile' + # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowOnConstant, AllowOnSelfClass. @@ -336,6 +297,7 @@ Style/ClassVars: - 'lib/rspec-puppet/support.rb' # Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). Style/CombinableLoops: Exclude: - 'spec/classes/catalogue_cache_spec.rb' @@ -353,15 +315,13 @@ Style/FormatString: Exclude: - 'lib/rspec-puppet/coverage.rb' -# Offense count: 14 -# This cop supports safe autocorrection (--autocorrect). -Style/IfUnlessModifier: +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: Exclude: - - 'lib/rspec-puppet/adapters.rb' - - 'lib/rspec-puppet/coverage.rb' - - 'lib/rspec-puppet/example/function_example_group.rb' - - 'lib/rspec-puppet/matchers/create_generic.rb' - - 'lib/rspec-puppet/support.rb' + - 'Rakefile' # Offense count: 5 Style/MissingRespondToMissing: @@ -390,6 +350,14 @@ Style/SlicingWithRange: Exclude: - 'lib/rspec-puppet/monkey_patches.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: RequireEnglish, EnforcedStyle. +# SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names +Style/SpecialGlobalVars: + Exclude: + - 'Rakefile' + # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. diff --git a/Gemfile b/Gemfile index 8f954448b..6252a780e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,10 +1,12 @@ -source ENV['GEM_SOURCE'] || "https://rubygems.org" +# frozen_string_literal: true + +source ENV['GEM_SOURCE'] || 'https://rubygems.org' gemspec def location_for(place_or_version, fake_version = nil) - git_url_regex = %r{\A(?(https?|git)[:@][^#]*)(#(?.*))?} - file_url_regex = %r{\Afile:\/\/(?.*)} + git_url_regex = /\A(?(https?|git)[:@][^#]*)(#(?.*))?/ + file_url_regex = %r{\Afile://(?.*)} if place_or_version && (git_url = place_or_version.match(git_url_regex)) [fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact @@ -16,15 +18,14 @@ def location_for(place_or_version, fake_version = nil) end group :development do + gem 'fuubar' gem 'pry' gem 'pry-stack_explorer' - gem 'fuubar' end group :test do - - gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) - gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) + gem 'facter', *location_for(ENV.fetch('FACTER_GEM_VERSION', nil)) + gem 'puppet', *location_for(ENV.fetch('PUPPET_GEM_VERSION', nil)) gem 'json_pure' gem 'sync' @@ -35,5 +36,5 @@ group :test do gem 'simplecov', require: false gem 'simplecov-console', require: false - gem 'win32-taskscheduler', :platforms => [:mingw, :x64_mingw, :mswin] + gem 'win32-taskscheduler', platforms: %i[mingw x64_mingw mswin] end diff --git a/Rakefile b/Rakefile index a99a212a7..547bbb18f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rake' require 'rspec/core/rake_task' require 'rubocop/rake_task' @@ -5,25 +7,25 @@ require 'bundler/gem_tasks' require 'fileutils' require 'puppet' -task :default => :test -task :spec => :test +task default: :test +task spec: :test require 'rspec-puppet/tasks/release_test' fixtures_dir = File.expand_path(File.join(__FILE__, '..', 'spec', 'fixtures', 'modules')) fixtures = { 'augeas_core' => { - :url => 'https://github.com/puppetlabs/puppetlabs-augeas_core', - :requirement => Gem::Requirement.new('>= 6.0.0'), + url: 'https://github.com/puppetlabs/puppetlabs-augeas_core', + requirement: Gem::Requirement.new('>= 6.0.0'), }, - 'stdlib' => { - :url => 'https://github.com/puppetlabs/puppetlabs-stdlib', - :requirement => Gem::Requirement.new('>= 0'), - :ref => '4.2.0', + 'stdlib' => { + url: 'https://github.com/puppetlabs/puppetlabs-stdlib', + requirement: Gem::Requirement.new('>= 0'), + ref: '4.2.0', }, - 'registry' => { - :url => 'https://github.com/puppetlabs/puppetlabs-registry', - :requirement => Gem::Requirement.new('>= 0'), + 'registry' => { + url: 'https://github.com/puppetlabs/puppetlabs-registry', + requirement: Gem::Requirement.new('>= 0'), }, } @@ -49,13 +51,13 @@ namespace :test do next unless fixture[:requirement].satisfied_by?(puppet_version) system('git', 'clone', fixture[:url], name) - fail unless $?.success? + raise unless $?.success? + + next unless fixture.key?(:ref) - if fixture.key?(:ref) - Dir.chdir(name) do - system('git', 'checkout', fixture[:ref]) - fail unless $?.success? - end + Dir.chdir(name) do + system('git', 'checkout', fixture[:ref]) + raise unless $?.success? end end end @@ -65,32 +67,29 @@ namespace :test do Dir.chdir(fixtures_dir) do fixtures.each do |name, _| next unless File.directory?(name) + FileUtils.rm_r(name) end end end task :unit do - begin - Rake::Task['test:setup'].invoke - ENV['COVERAGE'] = 'local' - Rake::Task['test:spec_unit'].invoke - ensure - ENV.delete('COVERAGE') - Rake::Task['test:teardown'].invoke - end - end -end - -task :test do - begin Rake::Task['test:setup'].invoke - Rake::Task['test:spec'].invoke + ENV['COVERAGE'] = 'local' + Rake::Task['test:spec_unit'].invoke ensure + ENV.delete('COVERAGE') Rake::Task['test:teardown'].invoke end end +task :test do + Rake::Task['test:setup'].invoke + Rake::Task['test:spec'].invoke +ensure + Rake::Task['test:teardown'].invoke +end + RuboCop::RakeTask.new(:rubocop) do |task| task.options = %w[-D -S -E] end @@ -98,7 +97,7 @@ end namespace :spec do desc 'Run RSpec code examples with coverage collection' task :coverage do - ENV['COVERAGE'] = 'yes' - Rake::Task['test'].invoke + ENV['COVERAGE'] = 'yes' + Rake::Task['test'].invoke end end diff --git a/bin/rspec-puppet-init b/bin/rspec-puppet-init index ea2cfdeb8..5affc92f2 100755 --- a/bin/rspec-puppet-init +++ b/bin/rspec-puppet-init @@ -7,7 +7,7 @@ require 'rspec-puppet' require 'optparse' options = { - module_name: nil + module_name: nil, } OptionParser.new do |opts| diff --git a/lib/rspec-puppet/adapters.rb b/lib/rspec-puppet/adapters.rb index ba2283f30..ca66255e2 100644 --- a/lib/rspec-puppet/adapters.rb +++ b/lib/rspec-puppet/adapters.rb @@ -53,13 +53,11 @@ def setup_puppet(example_group) [puppet_setting, get_setting(example_group, rspec_setting)] end.flatten default_hash = { confdir: '/dev/null', vardir: '/dev/null' } - if defined?(Puppet::Test::TestHelper) && Puppet::Test::TestHelper.respond_to?(:app_defaults_for_tests, true) - default_hash.merge!(Puppet::Test::TestHelper.send(:app_defaults_for_tests)) - end + default_hash.merge!(Puppet::Test::TestHelper.send(:app_defaults_for_tests)) if defined?(Puppet::Test::TestHelper) && Puppet::Test::TestHelper.respond_to?(:app_defaults_for_tests, true) settings_hash = default_hash.merge(Hash[*settings]) if Gem.win_platform? settings_hash.each_with_object(settings_hash) do |(k, v), h| - h[k] = v == '/dev/null' ? 'c:/nul/' : v + h[k] = (v == '/dev/null') ? 'c:/nul/' : v end end @@ -101,9 +99,9 @@ def setup_puppet(example_group) { environments: loader, current_environment: env, - loaders: Puppet::Pops::Loaders.new(env) + loaders: Puppet::Pops::Loaders.new(env), }, - 'Setup rspec-puppet environments' + 'Setup rspec-puppet environments', ) end @@ -119,9 +117,7 @@ def catalog(node, exported) node.environment = current_environment # Override $::environment to workaround PUP-5835, where Puppet otherwise # stores a symbol for the parameter - if node.parameters['environment'] != node.parameters['environment'].to_s - node.parameters['environment'] = current_environment.name.to_s - end + node.parameters['environment'] = current_environment.name.to_s if node.parameters['environment'] != node.parameters['environment'].to_s catalog = if exported # Use the compiler directly to skip the filtering done by the indirector @@ -148,7 +144,7 @@ def settings_map %i[environmentpath environmentpath], %i[hiera_config hiera_config], %i[strict_variables strict_variables], - %i[vendormoduledir vendormoduledir] + %i[vendormoduledir vendormoduledir], ] end @@ -187,7 +183,7 @@ def set_facter_impl(impl) def self.get [ - ['7.11', Base] + ['7.11', Base], ].each do |(version, klass)| return klass.new if Puppet::Util::Package.versioncmp(Puppet.version, version) >= 0 end diff --git a/lib/rspec-puppet/consts.rb b/lib/rspec-puppet/consts.rb index b79615f4a..a80e71264 100644 --- a/lib/rspec-puppet/consts.rb +++ b/lib/rspec-puppet/consts.rb @@ -5,24 +5,24 @@ module RSpec::Puppet::Consts posix: { 'File::PATH_SEPARATOR' => ':', 'File::ALT_SEPARATOR' => nil, - 'Pathname::SEPARATOR_PAT' => /#{Regexp.quote('/')}/ + 'Pathname::SEPARATOR_PAT' => /#{Regexp.quote('/')}/, }, windows: { 'File::PATH_SEPARATOR' => ';', 'File::ALT_SEPARATOR' => '\\', - 'Pathname::SEPARATOR_PAT' => /[#{Regexp.quote('\\')}#{Regexp.quote('/')}]/ - } + 'Pathname::SEPARATOR_PAT' => /[#{Regexp.quote('\\')}#{Regexp.quote('/')}]/, + }, }.freeze FEATURES = { posix: { posix: true, - microsoft_windows: false + microsoft_windows: false, }, windows: { posix: false, - microsoft_windows: true - } + microsoft_windows: true, + }, }.freeze def self.stub_consts_for(platform) diff --git a/lib/rspec-puppet/coverage.rb b/lib/rspec-puppet/coverage.rb index 5297e67c0..8b9597261 100644 --- a/lib/rspec-puppet/coverage.rb +++ b/lib/rspec-puppet/coverage.rb @@ -232,9 +232,7 @@ def coverage_test(coverage_desired, report) end # This is not available on RSpec 2.x - if coverage_results.execution_result.respond_to?(:pending_message) - coverage_results.execution_result.pending_message = report[:text] - end + coverage_results.execution_result.pending_message = report[:text] if coverage_results.execution_result.respond_to?(:pending_message) else puts "The desired coverage must be 0 <= x <= 100, not '#{coverage_desired.inspect}'" end @@ -259,7 +257,7 @@ def results text = [ "Total resources: #{report[:total]}", "Touched resources: #{report[:touched]}", - "Resource coverage: #{report[:coverage]}%" + "Resource coverage: #{report[:coverage]}%", ] if (report[:untouched]).positive? @@ -341,7 +339,7 @@ def to_s def to_hash { - touched: touched? + touched: touched?, } end diff --git a/lib/rspec-puppet/example/function_example_group.rb b/lib/rspec-puppet/example/function_example_group.rb index 683612968..17be1ef04 100644 --- a/lib/rspec-puppet/example/function_example_group.rb +++ b/lib/rspec-puppet/example/function_example_group.rb @@ -86,7 +86,7 @@ def subject def find_function(function_name = self.class.top_level_description) with_vardir do - env = adapter.current_environment + adapter.current_environment context_overrides = compiler.context_overrides func = nil @@ -99,9 +99,7 @@ def find_function(function_name = self.class.top_level_description) return func if func.func - if Puppet::Parser::Functions.function(function_name) - V3FunctionWrapper.new(function_name, scope.method(:"function_#{function_name}")) - end + V3FunctionWrapper.new(function_name, scope.method(:"function_#{function_name}")) if Puppet::Parser::Functions.function(function_name) end end @@ -148,7 +146,7 @@ def build_compiler node_options = { parameters: fact_values, - facts: node_facts + facts: node_facts, } stub_facts! fact_values @@ -157,9 +155,9 @@ def build_compiler Puppet.push_context( { - trusted_information: Puppet::Context::TrustedInformation.new('remote', node_name, trusted_values) + trusted_information: Puppet::Context::TrustedInformation.new('remote', node_name, trusted_values), }, - 'Context for spec trusted hash' + 'Context for spec trusted hash', ) compiler = Puppet::Parser::Compiler.new(node) @@ -168,9 +166,9 @@ def build_compiler Puppet.push_context( { loaders: loaders, - global_scope: compiler.context_overrides[:global_scope] + global_scope: compiler.context_overrides[:global_scope], }, - 'set globals' + 'set globals', ) compiler end diff --git a/lib/rspec-puppet/example/type_example_group.rb b/lib/rspec-puppet/example/type_example_group.rb index 35ab0e885..f9099a095 100644 --- a/lib/rspec-puppet/example/type_example_group.rb +++ b/lib/rspec-puppet/example/type_example_group.rb @@ -16,7 +16,7 @@ def subject # to pass all of the bits form the current scope # required to create it title, - my_params + my_params, ] end end diff --git a/lib/rspec-puppet/matchers/allow_value.rb b/lib/rspec-puppet/matchers/allow_value.rb index 473b02ac8..d0ac7fc40 100644 --- a/lib/rspec-puppet/matchers/allow_value.rb +++ b/lib/rspec-puppet/matchers/allow_value.rb @@ -28,7 +28,7 @@ def description end def failure_message - "expected that the type alias would #{description} but it raised the #{@error_msgs.length == 1 ? 'error' : 'errors'} #{@error_msgs.join(', ')}" + "expected that the type alias would #{description} but it raised the #{(@error_msgs.length == 1) ? 'error' : 'errors'} #{@error_msgs.join(', ')}" end def failure_message_when_negated diff --git a/lib/rspec-puppet/matchers/count_generic.rb b/lib/rspec-puppet/matchers/count_generic.rb index 8abf950ab..7a0e84289 100644 --- a/lib/rspec-puppet/matchers/count_generic.rb +++ b/lib/rspec-puppet/matchers/count_generic.rb @@ -6,7 +6,7 @@ class CountGeneric DEFAULT_RESOURCES = [ 'Class[main]', 'Class[Settings]', - 'Stage[main]' + 'Stage[main]', ].freeze attr_reader :resource_type @@ -46,10 +46,10 @@ def description desc << "contain exactly #{@expected_number}" if @type == 'class' - desc << (@expected_number == 1 ? 'class' : 'classes').to_s + desc << ((@expected_number == 1) ? 'class' : 'classes').to_s else desc << @resource_type.to_s unless @type == 'resource' - desc << (@expected_number == 1 ? 'resource' : 'resources').to_s + desc << ((@expected_number == 1) ? 'resource' : 'resources').to_s end desc.join(' ') diff --git a/lib/rspec-puppet/matchers/create_generic.rb b/lib/rspec-puppet/matchers/create_generic.rb index 19e4cc33b..d43e3952a 100644 --- a/lib/rspec-puppet/matchers/create_generic.rb +++ b/lib/rspec-puppet/matchers/create_generic.rb @@ -83,7 +83,6 @@ def method_missing(method, *args, &block) end def matches?(catalogue) - ret = true @catalogue = catalogue.is_a?(Puppet::Resource::Catalog) ? catalogue : catalogue.call resource = @catalogue.resource(@referenced_type, @title) @@ -104,14 +103,9 @@ def matches?(catalogue) 'name' end - if @expected_params.none? { |param| param.first.to_s == namevar } && rsrc_hsh.key?(namevar.to_sym) - rsrc_hsh.delete(namevar.to_sym) - end + rsrc_hsh.delete(namevar.to_sym) if @expected_params.none? { |param| param.first.to_s == namevar } && rsrc_hsh.key?(namevar.to_sym) - if @expected_params_count && rsrc_hsh.size != @expected_params_count - ret = false - (@errors ||= []) << "exactly #{@expected_params_count} parameters but the catalogue contains #{rsrc_hsh.size}" - end + (@errors ||= []) << "exactly #{@expected_params_count} parameters but the catalogue contains #{rsrc_hsh.size}" if @expected_params_count && rsrc_hsh.size != @expected_params_count check_params(rsrc_hsh, @expected_params, :should) if @expected_params.any? check_params(rsrc_hsh, @expected_undef_params, :not) if @expected_undef_params.any? @@ -207,12 +201,12 @@ def generate_param_list(list, type) output = [] list.each do |param, value| if value.nil? - output << "#{param} #{type == :not ? 'un' : ''}defined" + output << "#{param} #{(type == :not) ? 'un' : ''}defined" else - a = type == :not ? '!' : '=' + a = (type == :not) ? '!' : '=' b = value.is_a?(Regexp) ? '~' : '>' output << if (param.to_s == 'content') && value.is_a?(String) - "#{param} #{type == :not ? 'not ' : ''} supplied string" + "#{param} #{(type == :not) ? 'not ' : ''} supplied string" else "#{param} #{a}#{b} #{value.inspect}" end @@ -223,33 +217,25 @@ def generate_param_list(list, type) def check_befores(_catalogue, resource) @befores.each do |ref| - unless precedes?(resource, canonicalize_resource(ref)) - @errors << BeforeRelationshipError.new(resource.to_ref, ref) - end + @errors << BeforeRelationshipError.new(resource.to_ref, ref) unless precedes?(resource, canonicalize_resource(ref)) end end def check_requires(_catalogue, resource) @requires.each do |ref| - unless precedes?(canonicalize_resource(ref), resource) - @errors << RequireRelationshipError.new(resource.to_ref, ref) - end + @errors << RequireRelationshipError.new(resource.to_ref, ref) unless precedes?(canonicalize_resource(ref), resource) end end def check_notifies(_catalogue, resource) @notifies.each do |ref| - unless notifies?(resource, canonicalize_resource(ref)) - @errors << NotifyRelationshipError.new(resource.to_ref, ref) - end + @errors << NotifyRelationshipError.new(resource.to_ref, ref) unless notifies?(resource, canonicalize_resource(ref)) end end def check_subscribes(_catalogue, resource) @subscribes.each do |ref| - unless notifies?(canonicalize_resource(ref), resource) - @errors << SubscribeRelationshipError.new(resource.to_ref, ref) - end + @errors << SubscribeRelationshipError.new(resource.to_ref, ref) unless notifies?(canonicalize_resource(ref), resource) end end @@ -334,9 +320,7 @@ def precedes?(first, second) before_refs = relationship_refs(u, :before) + relationship_refs(u, :notify) require_refs = relationship_refs(v, :require) + relationship_refs(u, :subscribe) - if before_refs.include?(v.to_ref) || require_refs.include?(u.to_ref) || (before_refs & require_refs).any? - return true - end + return true if before_refs.include?(v.to_ref) || require_refs.include?(u.to_ref) || (before_refs & require_refs).any? end end diff --git a/lib/rspec-puppet/monkey_patches.rb b/lib/rspec-puppet/monkey_patches.rb index 798fb257d..05396b06d 100644 --- a/lib/rspec-puppet/monkey_patches.rb +++ b/lib/rspec-puppet/monkey_patches.rb @@ -175,7 +175,7 @@ def windows? module_function :windows? def actual_platform - @actual_platform ||= !!File::ALT_SEPARATOR ? :windows : :posix + @actual_platform ||= (!!File::ALT_SEPARATOR) ? :windows : :posix end module_function :actual_platform @@ -366,7 +366,7 @@ class Puppet::Module # defined. This check only makes sense when applying the catalogue to a host # and so can be safely stubbed out for unit testing. Puppet::Type.type(:file).provide(:windows).class_eval do - old_supports_acl = instance_method(:supports_acl?) if respond_to?(:supports_acl?) + instance_method(:supports_acl?) if respond_to?(:supports_acl?) def supports_acl?(_path) if RSpec::Puppet.rspec_puppet_example? @@ -376,7 +376,7 @@ def supports_acl?(_path) end end - old_manages_symlinks = instance_method(:manages_symlinks?) if respond_to?(:manages_symlinks?) + instance_method(:manages_symlinks?) if respond_to?(:manages_symlinks?) def manages_symlinks? if RSpec::Puppet.rspec_puppet_example? @@ -394,7 +394,7 @@ module Kernel alias old_require require def require(path) return if ['puppet/util/windows', - 'win32/registry'].include?(path) && RSpec::Puppet.rspec_puppet_example? && Puppet::Util::Platform.pretend_windows? + 'win32/registry',].include?(path) && RSpec::Puppet.rspec_puppet_example? && Puppet::Util::Platform.pretend_windows? old_require(path) end diff --git a/lib/rspec-puppet/monkey_patches/windows/taskschedulerconstants.rb b/lib/rspec-puppet/monkey_patches/windows/taskschedulerconstants.rb index b2db06498..c8af533f0 100644 --- a/lib/rspec-puppet/monkey_patches/windows/taskschedulerconstants.rb +++ b/lib/rspec-puppet/monkey_patches/windows/taskschedulerconstants.rb @@ -5,7 +5,7 @@ module Puppet module Windows module TaskSchedulerConstants SYSTEM_USERS = ['NT AUTHORITY\SYSTEM', 'SYSTEM', 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE', - 'BUILTIN\USERS', 'USERS'].freeze + 'BUILTIN\USERS', 'USERS',].freeze # Triggers @@ -221,7 +221,7 @@ module TaskSchedulerConstants CLSCTX_INPROC_SERVER = 0x1 CLSID_CTask = [0x148BD520, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03].pack('LSSC8') CLSID_CTaskScheduler = [0x148BD52A, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, - 0x03].pack('LSSC8') + 0x03,].pack('LSSC8') IID_ITaskScheduler = [0x148BD527, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03].pack('LSSC8') IID_ITask = [0x148BD524, 0xA2AB, 0x11CE, 0xB1, 0x1F, 0x00, 0xAA, 0x00, 0x53, 0x05, 0x03].pack('LSSC8') IID_IPersistFile = [0x0000010b, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46].pack('LSSC8') diff --git a/lib/rspec-puppet/setup.rb b/lib/rspec-puppet/setup.rb index f11985830..0e81258cd 100644 --- a/lib/rspec-puppet/setup.rb +++ b/lib/rspec-puppet/setup.rb @@ -55,7 +55,7 @@ def self.safe_setup_directories(module_name = nil, verbose = true) File.join('spec', 'hosts'), File.join('spec', 'fixtures'), File.join('spec', 'fixtures', 'manifests'), - File.join('spec', 'fixtures', 'modules') + File.join('spec', 'fixtures', 'modules'), ].each { |dir| safe_mkdir(dir, verbose) } target = File.join('spec', 'fixtures', 'modules', module_name) diff --git a/lib/rspec-puppet/support.rb b/lib/rspec-puppet/support.rb index ad0f8a4cf..46efbb6fc 100644 --- a/lib/rspec-puppet/support.rb +++ b/lib/rspec-puppet/support.rb @@ -102,11 +102,11 @@ def load_catalogue(type, exported = false, manifest_opts = {}) trusted_external_data: trusted_external_data_hash, ignored_cache_params: { hiera_data_value: hiera_data_value, - rspec_config_values: rspec_config_values - } + rspec_config_values: rspec_config_values, + }, ) - test_module = type == :host ? nil : class_name.split('::').first + test_module = (type == :host) ? nil : class_name.split('::').first if type == :define RSpec::Puppet::Coverage.add_filter(class_name, title) else @@ -205,14 +205,14 @@ def post_cond def facts_hash(node) base_facts = { 'clientversion' => Puppet::PUPPETVERSION, - 'environment' => environment.to_s + 'environment' => environment.to_s, } node_facts = { 'hostname' => node.split('.').first, 'fqdn' => node, 'domain' => node.split('.', 2).last, - 'clientcert' => node + 'clientcert' => node, } # Puppet 6.9.0 started setting a `serverip6` server fact which is set @@ -220,14 +220,12 @@ def facts_hash(node) # by FacterDB don't have an `ipaddress6` fact set, then the normal Facter # fact will be resolved, which can result in Ruby trying to load Windows # only gems on Linux. This is only a problem if facter is used. - if RSpec.configuration.facter_implementation.to_sym == :facter - node_facts['ipaddress6'] = 'FE80:0000:0000:0000:AAAA:AAAA:AAAA' - end + node_facts['ipaddress6'] = 'FE80:0000:0000:0000:AAAA:AAAA:AAAA' if RSpec.configuration.facter_implementation.to_sym == :facter networking_facts = { 'hostname' => node_facts['hostname'], 'fqdn' => node_facts['fqdn'], - 'domain' => node_facts['domain'] + 'domain' => node_facts['domain'], } result_facts = if RSpec.configuration.default_facts.any? @@ -275,9 +273,7 @@ def param_str(params) def trusted_facts_hash(_node_name) extensions = {} - if RSpec.configuration.default_trusted_facts.any? - extensions.merge!(munge_facts(RSpec.configuration.default_trusted_facts)) - end + extensions.merge!(munge_facts(RSpec.configuration.default_trusted_facts)) if RSpec.configuration.default_trusted_facts.any? extensions.merge!(munge_facts(trusted_facts)) if respond_to?(:trusted_facts) extensions @@ -286,9 +282,7 @@ def trusted_facts_hash(_node_name) def trusted_external_data_hash external_data = {} - if RSpec.configuration.default_trusted_external_data.any? - external_data.merge!(munge_facts(RSpec.configuration.default_trusted_external_data)) - end + external_data.merge!(munge_facts(RSpec.configuration.default_trusted_external_data)) if RSpec.configuration.default_trusted_external_data.any? external_data.merge!(munge_facts(trusted_external_data)) if respond_to?(:trusted_external_data) external_data @@ -381,7 +375,7 @@ def build_catalog_without_cache(nodename, facts_val, trusted_facts_val, hiera_co code: code, exported: exported, node_params: node_params, - trusted_external: {} + trusted_external: {}, }) end @@ -421,9 +415,9 @@ def build_catalog_without_cache_v2( trusted_info.push(trusted_external_data) Puppet.push_context( { - trusted_information: Puppet::Context::TrustedInformation.new(*trusted_info) + trusted_information: Puppet::Context::TrustedInformation.new(*trusted_info), }, - 'Context for spec trusted hash' + 'Context for spec trusted hash', ) node_obj.add_server_facts(server_facts_hash) @@ -476,9 +470,7 @@ def fixture_spec_hiera_conf(mod) Find.prune if %w[modules work-dir].any? do |dir| file.relative_path_from(path).to_s.start_with?("spec/fixtures/#{dir}") end - if file.basename.to_s.eql?(Puppet::Pops::Lookup::HieraConfig::CONFIG_FILE_NAME) - return @@fixture_hiera_configs[mod.name] = file.to_s - end + return @@fixture_hiera_configs[mod.name] = file.to_s if file.basename.to_s.eql?(Puppet::Pops::Lookup::HieraConfig::CONFIG_FILE_NAME) end end @@fixture_hiera_configs[mod.name] diff --git a/lib/rspec-puppet/tasks/release_test.rb b/lib/rspec-puppet/tasks/release_test.rb index 65518651f..e5bae66c5 100644 --- a/lib/rspec-puppet/tasks/release_test.rb +++ b/lib/rspec-puppet/tasks/release_test.rb @@ -19,7 +19,7 @@ 'garethr/garethr-docker', 'sensu/sensu-puppet', 'jenkinsci/puppet-jenkins', - 'rnelson0/puppet-local_user' + 'rnelson0/puppet-local_user', ] Bundler.with_clean_env do diff --git a/spec/classes/array_spec.rb b/spec/classes/array_spec.rb index a8ec22b75..f5844fae0 100644 --- a/spec/classes/array_spec.rb +++ b/spec/classes/array_spec.rb @@ -10,7 +10,7 @@ it { expect(subject).to contain_structured_data__def('thing').with( - { 'data' => %w[foo bar baz quux] } + { 'data' => %w[foo bar baz quux] }, ) } end @@ -22,7 +22,7 @@ it { expect(subject).to contain_structured_data__def('thing').with( - { 'data' => ['first', 1, 'second', 2] } + { 'data' => ['first', 1, 'second', 2] }, ) } end @@ -34,7 +34,7 @@ 'second', %w[third fourth], 5, - 6 + 6, ] } end @@ -45,8 +45,8 @@ 'second', %w[third fourth], 5, - 6 - ] } + 6, + ] }, ) } end diff --git a/spec/classes/facts_spec.rb b/spec/classes/facts_spec.rb index b91f56175..0719e911e 100644 --- a/spec/classes/facts_spec.rb +++ b/spec/classes/facts_spec.rb @@ -12,8 +12,8 @@ let(:facts) do { os: { - 'family' => family - } + 'family' => family, + }, } end @@ -27,8 +27,8 @@ let(:facts) do { os: { - family: family - } + family: family, + }, } end @@ -43,8 +43,8 @@ let(:facts) do { oS: { - family: family - } + family: family, + }, } end @@ -58,8 +58,8 @@ let(:facts) do { 'os' => { - 'family' => family - } + 'family' => family, + }, } end @@ -74,8 +74,8 @@ let(:facts) do { 'oS' => { - 'family' => family - } + 'family' => family, + }, } end @@ -91,8 +91,8 @@ let(:facts) do { os: { - 'family' => family - } + 'family' => family, + }, } end @@ -106,8 +106,8 @@ let(:facts) do { os: { - family: family - } + family: family, + }, } end @@ -122,8 +122,8 @@ let(:facts) do { Os: { - family: family - } + family: family, + }, } end @@ -137,8 +137,8 @@ let(:facts) do { 'os' => { - 'family' => family - } + 'family' => family, + }, } end @@ -153,8 +153,8 @@ let(:facts) do { 'Os' => { - 'family' => family - } + 'family' => family, + }, } end @@ -170,8 +170,8 @@ let(:facts) do { 'custom_fact' => { - 'MixedCase' => 'value' - } + 'MixedCase' => 'value', + }, } end diff --git a/spec/classes/hash_spec.rb b/spec/classes/hash_spec.rb index 464e09ab5..72f6de962 100644 --- a/spec/classes/hash_spec.rb +++ b/spec/classes/hash_spec.rb @@ -10,7 +10,7 @@ it { expect(subject).to contain_structured_data__def('thing').with( - { 'data' => { 'foo' => 'bar', 'baz' => 'quux' } } + { 'data' => { 'foo' => 'bar', 'baz' => 'quux' } }, ) } end @@ -22,7 +22,7 @@ it { expect(subject).to contain_structured_data__def('thing').with( - { 'data' => { 1 => 'uno', 2 => 'dos' } } + { 'data' => { 1 => 'uno', 2 => 'dos' } }, ) } end @@ -34,7 +34,7 @@ it { expect(subject).to contain_structured_data__def('thing').with( - { 'data' => { 'first' => 1, 'second' => 2 } } + { 'data' => { 'first' => 1, 'second' => 2 } }, ) } end @@ -47,8 +47,8 @@ 'sec.ond' => 2, 'third' => { 'alpha' => 'a', - 'beta' => 'b' - } + 'beta' => 'b', + }, } } end @@ -59,9 +59,9 @@ 'sec.ond' => 2, 'third' => { 'alpha' => 'a', - 'beta' => 'b' - } - } } + 'beta' => 'b', + }, + } }, ) } end diff --git a/spec/classes/hiera_integration_spec.rb b/spec/classes/hiera_integration_spec.rb index 0b5eaf341..4dfd0e07b 100644 --- a/spec/classes/hiera_integration_spec.rb +++ b/spec/classes/hiera_integration_spec.rb @@ -42,7 +42,7 @@ context 'with absolute fixture hiera config path' do before do RSpec.configuration.fixture_hiera_configs = { - 'hiera_test' => File.join(__FILE__, '../../fixtures/modules/hiera_test/spec/module_hiera.yaml') + 'hiera_test' => File.join(__FILE__, '../../fixtures/modules/hiera_test/spec/module_hiera.yaml'), } end @@ -84,7 +84,7 @@ context 'with absolute fixture hiera config path' do before do RSpec.configuration.fixture_hiera_configs = { - 'hiera_test' => File.join(__FILE__, '../../fixtures/modules/hiera_test/spec/module_hiera.yaml') + 'hiera_test' => File.join(__FILE__, '../../fixtures/modules/hiera_test/spec/module_hiera.yaml'), } end diff --git a/spec/classes/map_reduce_spec.rb b/spec/classes/map_reduce_spec.rb index fd5f992ff..8dadf0e06 100644 --- a/spec/classes/map_reduce_spec.rb +++ b/spec/classes/map_reduce_spec.rb @@ -5,7 +5,7 @@ describe 'map_reduce' do let(:params) do { - values: [0, 1, 2] + values: [0, 1, 2], } end diff --git a/spec/classes/node_params_spec.rb b/spec/classes/node_params_spec.rb index 2814b774f..e99f21959 100644 --- a/spec/classes/node_params_spec.rb +++ b/spec/classes/node_params_spec.rb @@ -11,7 +11,7 @@ false => false, integer: 5, float: 4.4, - nil: nil + nil: nil, } let(:node_params) { fuzzed } diff --git a/spec/classes/server_facts_spec.rb b/spec/classes/server_facts_spec.rb index a71b2ff8e..764889396 100644 --- a/spec/classes/server_facts_spec.rb +++ b/spec/classes/server_facts_spec.rb @@ -5,7 +5,7 @@ describe 'server_facts' do let(:facts) do { - 'networking' => { 'ip' => '192.168.1.10' } + 'networking' => { 'ip' => '192.168.1.10' }, } end let(:node) { 'test123.test.com' } diff --git a/spec/classes/sysctl_common_spec.rb b/spec/classes/sysctl_common_spec.rb index 38cee16c7..47cbb2cbb 100644 --- a/spec/classes/sysctl_common_spec.rb +++ b/spec/classes/sysctl_common_spec.rb @@ -20,7 +20,7 @@ it 'passes if the parameters are contained in the resource' do expect(subject).to contain_exec('sysctl/reload').with( 'refreshonly' => 'true', - 'returns' => [0, 2] + 'returns' => [0, 2], ) end end @@ -73,7 +73,7 @@ expect(subject).to contain_exec('sysctl/reload').only_with( command: '/sbin/sysctl -p /etc/sysctl.conf', refreshonly: true, - returns: [0, 2] + returns: [0, 2], ) } @@ -88,7 +88,7 @@ expect do expect(subject).to contain_exec('sysctl/reload').only_with( command: '/sbin/sysctl -p /etc/sysctl.conf', - returns: [0, 2] + returns: [0, 2], ) end.to raise_error(RSpec::Expectations::ExpectationNotMetError) end @@ -98,7 +98,7 @@ expect(subject).to contain_exec('sysctl/reload').only_with( command: '/sbin/sysctl -p /etc/sysctl.conf', refreshonly: true, - creates: '/tmp/bla' + creates: '/tmp/bla', ) end.to raise_error(RSpec::Expectations::ExpectationNotMetError) end diff --git a/spec/classes/test_basic_spec.rb b/spec/classes/test_basic_spec.rb index 0a1bdd2cf..b09bdaf2f 100644 --- a/spec/classes/test_basic_spec.rb +++ b/spec/classes/test_basic_spec.rb @@ -12,8 +12,8 @@ { fqdn: 'notthis.test.com', networking: { - primary: 'eth0' - } + primary: 'eth0', + }, } end @@ -32,7 +32,7 @@ let(:node) { 'mycertname.test.com' } let(:facts) do { - fqdn: 'myhostname.test.com' + fqdn: 'myhostname.test.com', } end diff --git a/spec/classes/test_provider_suitability_spec.rb b/spec/classes/test_provider_suitability_spec.rb index fb88f8261..034aeb19f 100644 --- a/spec/classes/test_provider_suitability_spec.rb +++ b/spec/classes/test_provider_suitability_spec.rb @@ -7,18 +7,18 @@ { operatingsystem: 'Darwin', osfamily: 'Darwin', - kernel: 'Darwin' + kernel: 'Darwin', }, { operatingsystem: 'CentOS', osfamily: 'RedHat', - kernel: 'Linux' + kernel: 'Linux', }, { operatingsystem: 'Solaris', osfamily: 'Solaris', - kernel: 'SunOS' - } + kernel: 'SunOS', + }, ].each do |f| context "On #{f[:operatingsystem]}" do let(:facts) { f } diff --git a/spec/classes/test_user_spec.rb b/spec/classes/test_user_spec.rb index 7a3aa66e8..a3092792d 100644 --- a/spec/classes/test_user_spec.rb +++ b/spec/classes/test_user_spec.rb @@ -6,7 +6,7 @@ it { expect(subject).to contain_user('luke').only_with({ 'ensure' => 'present', - 'uid' => '501' + 'uid' => '501', }) } end diff --git a/spec/classes/trusted_facts_spec.rb b/spec/classes/trusted_facts_spec.rb index b10648210..382802929 100644 --- a/spec/classes/trusted_facts_spec.rb +++ b/spec/classes/trusted_facts_spec.rb @@ -30,7 +30,7 @@ context 'with extensions' do extensions = { :pp_uuid => 'ED803750-E3C7-44F5-BB08-41A04433FE2E', - '1.3.6.1.4.1.34380.1.2.1' => 'ssl-termination' + '1.3.6.1.4.1.34380.1.2.1' => 'ssl-termination', } let(:trusted_facts) { extensions } let(:node) { 'trusted.example.com' } diff --git a/spec/classes/type_mismatch_spec.rb b/spec/classes/type_mismatch_spec.rb index 2f15f370e..48e07116c 100644 --- a/spec/classes/type_mismatch_spec.rb +++ b/spec/classes/type_mismatch_spec.rb @@ -8,8 +8,8 @@ it do expect(subject).not_to contain_type_mismatch__hash('bug').with_hash( 'foo' => { - 'bar' => {} - } + 'bar' => {}, + }, ) end @@ -17,8 +17,8 @@ expect do expect(subject).not_to contain_type_mismatch__hash('bug').with_hash( 'foo' => { - 'bar' => {} - } + 'bar' => {}, + }, ) end.not_to raise_error end diff --git a/spec/classes/undef_spec.rb b/spec/classes/undef_spec.rb index d8f3cc8f0..4471d0067 100644 --- a/spec/classes/undef_spec.rb +++ b/spec/classes/undef_spec.rb @@ -20,7 +20,7 @@ expect(subject).to contain_class('undef_test').only_with( required_attribute: 'some_string', - defaults_to_undef: nil + defaults_to_undef: nil, ) end end @@ -41,7 +41,7 @@ expect(subject).to contain_class('undef_test').only_with( required_attribute: 'some_string', - defaults_to_undef: nil + defaults_to_undef: nil, ) end end @@ -64,7 +64,7 @@ expect(subject).to contain_class('undef_test').only_with( required_attribute: nil, - defaults_to_undef: nil + defaults_to_undef: nil, ) end end @@ -85,7 +85,7 @@ expect(subject).to contain_class('undef_test').only_with( required_attribute: nil, - defaults_to_undef: nil + defaults_to_undef: nil, ) end end diff --git a/spec/defines/sysctl_before_spec.rb b/spec/defines/sysctl_before_spec.rb index 0bfc5b29c..508550690 100644 --- a/spec/defines/sysctl_before_spec.rb +++ b/spec/defines/sysctl_before_spec.rb @@ -19,7 +19,7 @@ let(:title) { 'test define' } let(:pre_condition) do ['# we need sysctl common', - 'class {"sysctl::common":}'] + 'class {"sysctl::common":}',] end let(:params) { { value: 'title' } } diff --git a/spec/functions/trusted_facts_lookup_spec.rb b/spec/functions/trusted_facts_lookup_spec.rb index 60d285f2b..6a9f8da3e 100644 --- a/spec/functions/trusted_facts_lookup_spec.rb +++ b/spec/functions/trusted_facts_lookup_spec.rb @@ -17,7 +17,7 @@ let(:trusted_facts) do { 'extra1' => '1', - 'extra2' => '2' + 'extra2' => '2', } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1ebc8271a..d91b52d10 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -7,7 +7,7 @@ SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::Console + SimpleCov::Formatter::Console, ] SimpleCov.start do diff --git a/spec/spec_helper_unit.rb b/spec/spec_helper_unit.rb index 88513884a..67dd53e38 100644 --- a/spec/spec_helper_unit.rb +++ b/spec/spec_helper_unit.rb @@ -7,7 +7,7 @@ SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, - SimpleCov::Formatter::Console + SimpleCov::Formatter::Console, ] SimpleCov.start do diff --git a/spec/support_spec.rb b/spec/support_spec.rb index 94576da75..b6aa8cb6f 100644 --- a/spec/support_spec.rb +++ b/spec/support_spec.rb @@ -82,8 +82,8 @@ 'hostname' => 'fy73bdiqazmyj62', 'networking' => { 'hostname' => 'fy73bdiqazmyj62', - 'fqdn' => 'fy73bdiqazmyj62.delivery.puppetlabs.net' - } + 'fqdn' => 'fy73bdiqazmyj62.delivery.puppetlabs.net', + }, } end @@ -100,9 +100,9 @@ 'os' => { 'family' => family, 'version' => { - 'major' => '10' - } - } + 'major' => '10', + }, + }, }) end @@ -114,7 +114,7 @@ context 'with osfamily fact' do let(:build_hash) do super().merge({ - 'osfamily' => family + 'osfamily' => family, }) end diff --git a/spec/types/valid_provider_spec.rb b/spec/types/valid_provider_spec.rb index b5ccfac93..58dc8c170 100644 --- a/spec/types/valid_provider_spec.rb +++ b/spec/types/valid_provider_spec.rb @@ -13,7 +13,7 @@ { parameters: { baddies: %w[one two], goodies: %w[three four] }, properties: { baddies: %w[five fix], goodies: %w[seven eight] }, - features: { baddies: %w[nine ten], goodies: %w[eleven twelve] } + features: { baddies: %w[nine ten], goodies: %w[eleven twelve] }, }.each do |k, v| describe "#{k} checks" do [v[:baddies], v[:baddies].first].each do |baddies| @@ -22,7 +22,7 @@ expect(subject).to be_valid_type.send(:"with_#{k}", baddies) end.to raise_error( RSpec::Expectations::ExpectationNotMetError, - /Invalid #{k}: #{Array(baddies).join(',')}/ + /Invalid #{k}: #{Array(baddies).join(',')}/, ) end end @@ -50,7 +50,7 @@ expect(subject).to be_valid_type.with_provider(:non_matching) end.to raise_error( RSpec::Expectations::ExpectationNotMetError, - /Expected provider: non_matching does not match: default/ + /Expected provider: non_matching does not match: default/, ) end @@ -61,17 +61,17 @@ it 'fails with invalid parameters' do expect do expect(subject).to be_valid_type.with_set_attributes( - four: 'three' + four: 'three', ) end.to raise_error( Puppet::Error, - %r{Valid values match /\(one\|two\)/} + %r{Valid values match /\(one\|two\)/}, ) end it 'does not fail with valid parameters' do expect(subject).to be_valid_type.with_set_attributes( - four: 'one' + four: 'one', ) end end diff --git a/spec/unit/coverage_spec.rb b/spec/unit/coverage_spec.rb index 0ee8bb8a3..22c00ded2 100644 --- a/spec/unit/coverage_spec.rb +++ b/spec/unit/coverage_spec.rb @@ -48,7 +48,7 @@ [/escapism\\\\\Z/, /\ANotify\[.*escapism\\\\\]\z/], [/escapism\\\\$/, /\ANotify\[.*escapism\\\\\]\z/], [/escapism\\\\\$/, /\ANotify\[.*escapism\\\\\$.*\]\z/], - [/escapism\\\\\\\$/, /\ANotify\[.*escapism\\\\\\\$.*\]\z/] + [/escapism\\\\\\\$/, /\ANotify\[.*escapism\\\\\\\$.*\]\z/], ].each do |input, filter| it "maps #{input} to #{filter}" do subject.add_filter_regex('notify', input) diff --git a/spec/unit/facter_impl_spec.rb b/spec/unit/facter_impl_spec.rb index 11b4719a9..7f798f0fa 100644 --- a/spec/unit/facter_impl_spec.rb +++ b/spec/unit/facter_impl_spec.rb @@ -13,7 +13,7 @@ 'int_fact' => 3, 'true_fact' => true, 'false_fact' => false, - 'os' => { 'name' => 'my_os', 'release' => { 'major' => '42' } } + 'os' => { 'name' => 'my_os', 'release' => { 'major' => '42' } }, } end diff --git a/spec/unit/matchers/compile_spec.rb b/spec/unit/matchers/compile_spec.rb index dcf757ffc..0892d47f7 100644 --- a/spec/unit/matchers/compile_spec.rb +++ b/spec/unit/matchers/compile_spec.rb @@ -18,7 +18,7 @@ it { expect(subject).to have_attributes( - description: 'compile into a catalogue without dependency cycles' + description: 'compile into a catalogue without dependency cycles', ) } @@ -29,7 +29,7 @@ it { expect(subject).to have_attributes( - description: 'fail to compile and raise the error "example"' + description: 'fail to compile and raise the error "example"', ) } @@ -38,7 +38,7 @@ it { expect(subject).to have_attributes( - failure_message: a_string_starting_with('expected that the catalogue would fail to compile and raise the error "example"') + failure_message: a_string_starting_with('expected that the catalogue would fail to compile and raise the error "example"'), ) } end @@ -51,7 +51,7 @@ it { expect(subject).to have_attributes( - description: 'fail to compile and raise an error matching /example/' + description: 'fail to compile and raise an error matching /example/', ) } @@ -60,7 +60,7 @@ it { expect(subject).to have_attributes( - failure_message: a_string_starting_with('expected that the catalogue would fail to compile and raise an error matching /example/') + failure_message: a_string_starting_with('expected that the catalogue would fail to compile and raise an error matching /example/'), ) } end @@ -77,7 +77,7 @@ it { expect(subject).to have_attributes( - failure_message: a_string_matching(%r{\Aerror during compilation: Could not (retrieve dependency|find resource) 'File\[/tmp/missing\]'}) + failure_message: a_string_matching(%r{\Aerror during compilation: Could not (retrieve dependency|find resource) 'File\[/tmp/missing\]'}), ) } end @@ -93,7 +93,7 @@ it { expect(subject).to have_attributes( - failure_message: a_string_starting_with('error during compilation: ') + failure_message: a_string_starting_with('error during compilation: '), ) } end @@ -114,7 +114,7 @@ it { expect(subject).to have_attributes( - failure_message: a_string_starting_with('dependency cycles found: ') + failure_message: a_string_starting_with('dependency cycles found: '), ) } end @@ -130,7 +130,7 @@ it { expect(subject).to have_attributes( description: 'fail to compile and raise the error "example"', - failure_message: a_string_starting_with('dependency cycles found: ') + failure_message: a_string_starting_with('dependency cycles found: '), ) } end @@ -147,7 +147,7 @@ it { expect(subject).to have_attributes( description: 'fail to compile and raise an error matching /example/', - failure_message: a_string_starting_with('dependency cycles found: ') + failure_message: a_string_starting_with('dependency cycles found: '), ) } end @@ -165,7 +165,7 @@ it { expect(subject).to have_attributes( description: 'compile into a catalogue without dependency cycles', - failure_message: a_string_starting_with('error during compilation: ') + failure_message: a_string_starting_with('error during compilation: '), ) } end @@ -181,7 +181,7 @@ it { expect(subject).to have_attributes( - description: "fail to compile and raise the error \"#{expected_error}\"" + description: "fail to compile and raise the error \"#{expected_error}\"", ) } @@ -190,7 +190,7 @@ it { expect(subject).to have_attributes( - failure_message: a_string_starting_with('error during compilation: ') + failure_message: a_string_starting_with('error during compilation: '), ) } end @@ -203,7 +203,7 @@ it { expect(subject).to have_attributes( - description: 'fail to compile and raise an error matching /failure/' + description: 'fail to compile and raise an error matching /failure/', ) } @@ -212,7 +212,7 @@ it { expect(subject).to have_attributes( - failure_message: a_string_starting_with('error during compilation: ') + failure_message: a_string_starting_with('error during compilation: '), ) } end diff --git a/spec/unit/matchers/count_generic_spec.rb b/spec/unit/matchers/count_generic_spec.rb index 03cac7501..679ca7567 100644 --- a/spec/unit/matchers/count_generic_spec.rb +++ b/spec/unit/matchers/count_generic_spec.rb @@ -23,7 +23,7 @@ [ %w[Class main], %w[Class Settings], - %w[Stage main] + %w[Stage main], ] end @@ -147,7 +147,7 @@ let(:resources) do [ ['Class', 'test'], - ['Node', 'testhost.test.com'] + ['Node', 'testhost.test.com'], ] end @@ -160,7 +160,7 @@ super() + [ ['File', '/tmp/testfile'], ['Exec', 'some command'], - ['Service', 'a service'] + ['Service', 'a service'], ] end @@ -188,7 +188,7 @@ let(:resources) do [ %w[Class test], - %w[File testfile] + %w[File testfile], ] end diff --git a/spec/unit/monkey_patches_spec.rb b/spec/unit/monkey_patches_spec.rb index 4fdffd31c..5c9d2f5cd 100644 --- a/spec/unit/monkey_patches_spec.rb +++ b/spec/unit/monkey_patches_spec.rb @@ -136,7 +136,7 @@ Puppet::Module.new( 'escape', File.join(RSpec.configuration.module_path, 'escape'), - 'production' + 'production', ) end