Skip to content

Commit

Permalink
Simplify select.map to filter_map
Browse files Browse the repository at this point in the history
This commit simplifies instances where map is called on a select call to
instead use filter_map.
  • Loading branch information
mhashizume committed Apr 19, 2024
1 parent 7769306 commit b1207b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions spec/unit/functions/lookup_fixture_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def compile_and_get_notifications(code)
Puppet[:code] = code
node.environment.check_for_reparse
catalog = block_given? ? compiler.compile { |cat| yield(compiler.topscope); cat } : compiler.compile
catalog.resources.map(&:ref).select { |r| r.start_with?('Notify[') }.map { |r| r[7..-2] }
catalog.resources.map(&:ref).filter_map { |r| r[7..-2] if r.start_with?('Notify[') }
end

# There is a fully configured 'production' environment in fixtures at this location
Expand Down Expand Up @@ -376,7 +376,7 @@ def compile_and_get_notifications(code)
Puppet[:code] = "include bad_data\nlookup('bad_data::b')"
expect { compiler.compile }.to raise_error(Puppet::ParseError, /did not find a value for the name 'bad_data::b'/)
end
warnings = logs.select { |log| log.level == :warning }.map { |log| log.message }
warnings = logs.filter_map { |log| log.message if log.level == :warning }
expect(warnings).to include("Module 'bad_data': Value returned from deprecated API function 'bad_data::data' must use keys qualified with the name of the module; got b")
end

Expand All @@ -390,7 +390,7 @@ def compile_and_get_notifications(code)
PUPPET
expect(resources).to include('module_c')
end
warnings = logs.select { |log| log.level == :warning }.map { |log| log.message }
warnings = logs.filter_map { |log| log.message if log.level == :warning }
expect(warnings).to include("Module 'bad_data': Value returned from deprecated API function 'bad_data::data' must use keys qualified with the name of the module; got b")
end

Expand Down

0 comments on commit b1207b9

Please sign in to comment.