Skip to content

Commit

Permalink
Add tests for symbol conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Jun 7, 2024
1 parent 6503541 commit ca8070d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 35 deletions.
45 changes: 11 additions & 34 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-12-12 12:48:14 UTC using RuboCop version 1.57.2.
# on 2024-06-07 12:27:41 UTC using RuboCop version 1.63.5.
# 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
Expand All @@ -20,11 +20,12 @@ Lint/SuppressedException:

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AutoCorrect.
Lint/UselessAssignment:
Exclude:
- 'spec/facts_spec.rb'

# Offense count: 2
# Offense count: 3
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Expand All @@ -38,7 +39,7 @@ Performance/MapCompact:
Exclude:
- 'lib/facterdb.rb'

# Offense count: 7
# Offense count: 8
# This cop supports unsafe autocorrection (--autocorrect-all).
Performance/StringInclude:
Exclude:
Expand All @@ -64,7 +65,7 @@ RSpec/DescribeClass:

# Offense count: 12
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: SkipBlocks, EnforcedStyle.
# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants.
# SupportedStyles: described_class, explicit
RSpec/DescribedClass:
Exclude:
Expand All @@ -75,14 +76,14 @@ RSpec/DescribedClass:
RSpec/ExampleLength:
Max: 9

# Offense count: 4
# Offense count: 3
RSpec/MultipleExpectations:
Max: 7

# Offense count: 11
# Offense count: 19
# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 6
Max: 7

# Offense count: 11
# Configuration parameters: AllowedGroups.
Expand Down Expand Up @@ -114,7 +115,7 @@ Style/Documentation:
- 'lib/facterdb.rb'
- 'lib/facterdb/bin.rb'

# Offense count: 13
# Offense count: 12
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Expand All @@ -141,24 +142,6 @@ Style/HashEachMethods:
Exclude:
- 'spec/facts_spec.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/HashTransformKeys:
Exclude:
- 'lib/facterdb.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'lib/facterdb.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/MapToHash:
Exclude:
- 'lib/facterdb.rb'

# Offense count: 1
Style/MixinUsage:
Exclude:
Expand All @@ -182,19 +165,13 @@ Style/NumericPredicate:
- 'spec/**/*'
- 'Rakefile'

# Offense count: 1
# Offense count: 2
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/facterdb.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/SlicingWithRange:
Exclude:
- 'Rakefile'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Expand All @@ -215,4 +192,4 @@ Style/SymbolProc:
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 179
Max: 154
23 changes: 22 additions & 1 deletion spec/facter_db_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,35 @@
end

describe '.get_facts' do
subject(:result) { FacterDB.get_facts(filter) }
subject(:result) { FacterDB.get_facts(filter, symbolize_keys: symbolize_keys) }

let(:filter) { nil }
let(:symbolize_keys) { nil }

context 'without parameters' do
include_examples 'returns a result'
end

context 'with stringified output' do
let(:symbolize_keys) { false }

it 'returns strings as keys in factsets' do
result.each do |factset|
expect(factset.keys).to all(be_an_instance_of(String))
end
end
end

context 'with symbolized output' do
let(:symbolize_keys) { true }

it 'returns strings as keys in factsets' do
result.each do |factset|
expect(factset.keys).to all(be_an_instance_of(Symbol))
end
end
end

context 'with an Array filter' do
let(:filter) { [osfamily: 'Debian'] }

Expand Down

0 comments on commit ca8070d

Please sign in to comment.