Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
Merge c2726b0 into 2c47d6c
Browse files Browse the repository at this point in the history
  • Loading branch information
oanatmaria authored Mar 26, 2020
2 parents 2c47d6c + c2726b0 commit 73d59e7
Show file tree
Hide file tree
Showing 20 changed files with 145 additions and 176 deletions.
33 changes: 3 additions & 30 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 --exclude-limit 1000`
# on 2020-03-26 14:40:44 +0200 using RuboCop version 0.74.0.
# on 2020-03-26 19:27:19 +0200 using RuboCop version 0.74.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
Expand Down Expand Up @@ -30,32 +30,7 @@ RSpec/AnyInstance:
- 'spec/framework/core/options/options_validator_spec.rb'
- 'spec/mocks/util.rb'

# Offense count: 70
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/custom_facts/core/execution/posix_spec.rb'
- 'spec/custom_facts/core/execution/windows_spec.rb'
- 'spec/custom_facts/shared_contexts/platform.rb'
- 'spec/custom_facts/util/parser_spec.rb'
- 'spec/facter/fact_filter_spec.rb'
- 'spec/facter/facter_spec.rb'
- 'spec/facter/facts/macosx/is_virtual_spec.rb'
- 'spec/facter/resolvers/solaris/current_zone_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/solaris_release_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/zfs_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/zone_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/zpool_resolver_spec.rb'
- 'spec/facter/resolvers/ssh_resolver_spec.rb'
- 'spec/facter/resolvers/utils/windows/network_utils_spec.rb'
- 'spec/framework/config/config_reader_spec.rb'
- 'spec/framework/core/fact_loaders/external_fact_loader_spec.rb'
- 'spec/framework/core/fact_loaders/internal_fact_loader_spec.rb'
- 'spec/framework/core/options_spec.rb'
- 'spec/framework/formatters/legacy_fact_formatter_spec.rb'

# Offense count: 29
# Offense count: 27
RSpec/ExpectInHook:
Exclude:
- 'spec/custom_facts/core/execution/fact_manager_spec.rb'
Expand Down Expand Up @@ -177,7 +152,7 @@ RSpec/LeakyConstantDeclaration:
- 'spec/facter/resolvers/macosx/mountpoints_resolver_spec.rb'
- 'spec/facter/resolvers/utils/windows/network_utils_spec.rb'

# Offense count: 317
# Offense count: 315
# Configuration parameters: EnforcedStyle.
# SupportedStyles: have_received, receive
RSpec/MessageSpies:
Expand Down Expand Up @@ -300,9 +275,7 @@ RSpec/MessageSpies:
- 'spec/facter/facts/windows/scope6_interfaces_spec.rb'
- 'spec/facter/resolvers/aix/ffi_helper_spec.rb'
- 'spec/facter/resolvers/lpar_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/current_zone_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/zfs_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/zone_resolver_spec.rb'
- 'spec/facter/resolvers/solaris/zpool_resolver_spec.rb'
- 'spec/facter/resolvers/ssh_resolver_spec.rb'
- 'spec/facter/resolvers/utils/aix/odm_query_spec.rb'
Expand Down
4 changes: 2 additions & 2 deletions spec/custom_facts/core/execution/posix_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
allow(subject).to receive(:search_paths).and_return ['/bin', '/sbin', '/usr/sbin']
end

context 'and provided with an absolute path' do
context 'when provided with an absolute path' do
it 'returns the binary if executable' do
expect(FileTest).to receive(:file?).with('/opt/foo').and_return true
expect(File).to receive(:executable?).with('/opt/foo').and_return true
Expand All @@ -32,7 +32,7 @@
end
end

context 'and not provided with an absolute path' do
context "when it isn't provided with an absolute path" do
it 'returns the absolute path if found' do
expect(FileTest).not_to receive(:file?).with('/bin/foo')
expect(File).to receive(:executable?).with('/bin/foo').and_return false
Expand Down
6 changes: 3 additions & 3 deletions spec/custom_facts/core/execution/windows_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
end

describe '#execute' do
context 'with expand false' do
context 'when expand is false' do
subject(:executor) { Facter::Core::Execution::Windows.new }

it 'raises exception' do
Expand All @@ -28,7 +28,7 @@
allow(ENV).to receive(:[]).with('PATHEXT').and_return nil
end

context 'and provided with an absolute path' do
context 'when it is provided with an absolute path' do
it 'returns the binary if executable' do
expect(File).to receive(:executable?).with('C:\Tools\foo.exe').and_return true
expect(File).to receive(:executable?).with('\\\\remote\dir\foo.exe').and_return true
Expand All @@ -46,7 +46,7 @@
end
end

context 'and not provided with an absolute path' do
context 'when it is not provided with an absolute path' do
it 'returns the absolute path if found' do
expect(File).to receive(:executable?).with('C:\Windows\system32\foo.exe').and_return false
expect(File).to receive(:executable?).with('C:\Windows\foo.exe').and_return true
Expand Down
4 changes: 2 additions & 2 deletions spec/custom_facts/shared_contexts/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
#
#
shared_context 'windows', as_platform: :windows do
shared_context 'when windows', as_platform: :windows do
before do
allow(LegacyFacter).to receive(:value).and_return('Windows')
allow(LegacyFacter::Util::Config).to receive(:windows?).and_return true
Expand All @@ -30,7 +30,7 @@
end
end

shared_context 'posix', as_platform: :posix do
shared_context 'when posix', as_platform: :posix do
before do
LegacyFacter::Util::Config.stubs(:windows?).returns false
end
Expand Down
20 changes: 10 additions & 10 deletions spec/custom_facts/util/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

let(:data) { { 'one' => 'two', 'three' => 'four' } }

describe 'extension_matches? function' do
describe '#extension_matches?' do
it 'matches extensions when subclass uses match_extension' do
expect(LegacyFacter::Util::Parser.extension_matches?('myfile.foobar', 'foobar')).to be true
end
Expand All @@ -34,7 +34,7 @@
end
end

describe 'parse_executable_output' do
describe '#parse_executable_output' do
subject(:parser) { LegacyFacter::Util::Parser::Base.new('myfile.sh') }

let(:yaml_data) { "one: two\nthree: four\n" }
Expand Down Expand Up @@ -95,27 +95,27 @@
end
end

context 'well formed data' do
context 'when is well formed data' do
let(:data_in_txt) { "one=two\nthree=four\n" }

it_behaves_like 'txt parser'
end

context 'extra equal sign' do
context 'when there is an extra equal sign' do
let(:data_in_txt) { "one=two\nthree=four=five\n" }
let(:data) { { 'one' => 'two', 'three' => 'four=five' } }

it_behaves_like 'txt parser'
end

context 'extra data' do
context 'when there is extra data' do
let(:data_in_txt) { "one=two\nfive\nthree=four\n" }

it_behaves_like 'txt parser'
end
end

describe 'scripts' do
describe '#parser_for scripts' do
let(:ext) { LegacyFacter::Util::Config.windows? ? '.bat' : '.sh' }
let(:cmd) { "/tmp/foo#{ext}" }
let(:data_in_txt) { "one=two\nthree=four\n" }
Expand Down Expand Up @@ -159,7 +159,7 @@ def expects_parser_to_return_nil_for_directory(path)
expects_script_to_return(path, data_in_txt, data)
end

context 'exe, bat, cmd, and com files' do
describe '#parser_for exe, bat, cmd, and com files' do
let(:cmds) { ['/tmp/foo.bat', '/tmp/foo.cmd', '/tmp/foo.exe', '/tmp/foo.com'] }

before do
Expand All @@ -186,7 +186,7 @@ def expects_parser_to_return_nil_for_directory(path)
end
end

describe 'powershell parser' do
describe '#parser_for powershell' do
let(:ps1) { '/tmp/foo.ps1' }

def expects_to_parse_powershell(cmd, result)
Expand All @@ -210,7 +210,7 @@ def expects_to_parse_powershell(cmd, result)
expects_to_parse_powershell(ps1, data)
end

describe 'when executing powershell', if: LegacyFacter::Util::Config.windows? do
context 'when executing powershell', if: LegacyFacter::Util::Config.windows? do
let(:sysnative_powershell) { "#{ENV['SYSTEMROOT']}\\sysnative\\WindowsPowershell\\v1.0\\powershell.exe" }
let(:system32_powershell) { "#{ENV['SYSTEMROOT']}\\system32\\WindowsPowershell\\v1.0\\powershell.exe" }

Expand Down Expand Up @@ -244,7 +244,7 @@ def expects_to_parse_powershell(cmd, result)
end
end

describe 'nothing parser' do
context 'when nothing parser' do
it 'uses the nothing parser when there is no other parser' do
expect(LegacyFacter::Util::Parser.parser_for('this.is.not.valid').results).to be nil
end
Expand Down
10 changes: 5 additions & 5 deletions spec/facter/fact_filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

describe Facter::FactFilter do
describe '#filter_facts!' do
context 'value is a hash' do
context 'hash keys are symbols' do
context 'when value is a hash' do
context 'with hash keys as symbols' do
let(:fact_value) { { full: '18.7.0', major: '18', minor: 7 } }
let(:resolved_fact) { Facter::ResolvedFact.new('os.release', fact_value) }

Expand All @@ -18,7 +18,7 @@
end
end

context 'hash keys are strings and symbols' do
context 'when hash keys are strings and symbols' do
let(:fact_value) { { '/key1' => 'value_1', key2: 'value_2' } }
let(:resolved_fact) { Facter::ResolvedFact.new('my.fact', fact_value) }

Expand All @@ -34,7 +34,7 @@
end
end

context 'value is a string' do
context 'with value string' do
let(:fact_value) { 'value_1' }
let(:resolved_fact) { Facter::ResolvedFact.new('my.fact', fact_value) }

Expand All @@ -49,7 +49,7 @@
end
end

context 'filter legacy' do
context 'when filter legacy' do
let(:fact_value) { 'value_1' }
let(:legacy_resolved_fact) { Facter::ResolvedFact.new('operatingsystem', fact_value, :legacy) }
let(:core_resolved_fact) { Facter::ResolvedFact.new('os.name', fact_value, :core) }
Expand Down
2 changes: 1 addition & 1 deletion spec/facter/facter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
expect(formatted_facts).to eq([expected_json_output, 0])
end

context '--strict' do
context 'when provided with --strict option' do
before do
allow(Facter::Options).to receive(:[]).with(:config)
end
Expand Down
10 changes: 5 additions & 5 deletions spec/facter/facts/macosx/is_virtual_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
fact.call_the_resolver
end

context 'on virtual machine' do
context 'on vmware' do
context 'when on virtual machine' do
context 'with hypervisor vmware' do
before do
allow(Facter::Resolvers::SystemProfiler)
.to receive(:resolve)
Expand All @@ -54,7 +54,7 @@
end
end

context 'on VirtualBox' do
context 'when hypervisor VirtualBox' do
before do
allow(Facter::Resolvers::SystemProfiler)
.to receive(:resolve)
Expand All @@ -71,7 +71,7 @@
end
end

context 'on Parallels' do
context 'when hypervisor Parallels' do
before do
allow(Facter::Resolvers::SystemProfiler)
.to receive(:resolve)
Expand All @@ -89,7 +89,7 @@
end
end

context 'on physical machine' do
context 'when on physical machine' do
it 'returns resolved fact with false value' do
expect(fact.call_the_resolver)
.to be_an_instance_of(Facter::ResolvedFact)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Facter::Resolvers::SolarisZone.invalidate_cache
end

context 'Resolve zone facts' do
context 'when can resolve zone facts' do
let(:zone_name_output) { 'global' }
let(:st) { 'exit 0' }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Facter::Resolvers::SolarisRelease.invalidate_cache
end

context 'Resolve os release facts' do
context 'when can resolve os release facts' do
let(:output) { load_fixture('os_release_solaris').read }
let(:st) { 'exit 0' }

Expand Down
4 changes: 2 additions & 2 deletions spec/facter/resolvers/solaris/zfs_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

let(:st) { 'exit 0' }

context 'Resolve zfs facts' do
context 'when zfs command is found' do
let(:output) { load_fixture('zfs').read }

it 'returns zfs version fact' do
Expand All @@ -29,7 +29,7 @@
end
end

context 'Resolve zfs facts when zfs command is not found' do
context 'when zfs command is not found' do
let(:output) { 'zfs command not found' }

it 'returns nil for zfs version fact' do
Expand Down
2 changes: 1 addition & 1 deletion spec/facter/resolvers/solaris/zone_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Facter::Resolvers::SolarisZone.invalidate_cache
end

context 'Resolve zone facts' do
context 'when it can resolve zone facts' do
let(:output) { '0:global:running:/::solaris:shared:-:none:' }
let(:st) { 'exit 0' }

Expand Down
4 changes: 2 additions & 2 deletions spec/facter/resolvers/solaris/zpool_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

let(:st) { 'exit 0' }

context 'Resolve ZPool facts' do
context 'when zpool command is found' do
let(:output) { load_fixture('zpool').read }

it 'return zpool version fact' do
Expand All @@ -30,7 +30,7 @@
end
end

context 'Resolve ZPool facts if zpool command is not found' do
context 'when zpool command is not found' do
let(:output) { 'zpool command not found' }

it 'returns nil for zpool version fact' do
Expand Down
2 changes: 1 addition & 1 deletion spec/facter/resolvers/ssh_resolver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
Facter::Resolvers::SshResolver.invalidate_cache
end

context 'ecdsa file exists' do
context 'when ecdsa file exists' do
let(:ecdsa_content) { load_fixture('ecdsa').read.strip! }
let(:rsa_content) { load_fixture('rsa').read.strip! }
let(:ed25519_content) { load_fixture('ed25519').read.strip! }
Expand Down
Loading

0 comments on commit 73d59e7

Please sign in to comment.