Skip to content

Commit

Permalink
Merge pull request #1845 from voxpupuli/dependabot/bundler/voxpupuli-…
Browse files Browse the repository at this point in the history
…rubocop-tw-2.3.0

build(deps-dev): update voxpupuli-rubocop requirement from ~> 2.0.0 to ~> 2.3.0
  • Loading branch information
bastelfreak authored Jan 8, 2024
2 parents d2f1392 + 3695b24 commit c32b6d2
Show file tree
Hide file tree
Showing 22 changed files with 200 additions and 154 deletions.
56 changes: 51 additions & 5 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-05-30 09:17:22 UTC using RuboCop version 1.50.2.
# on 2024-01-08 14:04:43 UTC using RuboCop version 1.59.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 @@ -61,6 +61,7 @@ Lint/ShadowingOuterLocalVariable:
- 'lib/beaker/perf.rb'

# Offense count: 12
# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/UselessAssignment:
Exclude:
- 'acceptance/tests/base/dsl/helpers/host_helpers/curl_with_retries_test.rb'
Expand Down Expand Up @@ -107,6 +108,7 @@ Naming/HeredocDelimiterNaming:
- 'spec/beaker/test_case_spec.rb'

# Offense count: 2
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Expand All @@ -128,22 +130,32 @@ RSpec/AnyInstance:
- 'spec/beaker/host/windows/file_spec.rb'
- 'spec/beaker/subcommand_spec.rb'

# Offense count: 12
# Offense count: 30
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/BeEq:
Exclude:
- 'spec/beaker/cli_spec.rb'
- 'spec/beaker/dsl/roles_spec.rb'
- 'spec/beaker/host/pswindows/file_spec.rb'
- 'spec/beaker/host/windows/exec_spec.rb'
- 'spec/beaker/host_spec.rb'
- 'spec/beaker/shared/semvar_spec.rb'
- 'spec/beaker/subcommand/subcommand_util_spec.rb'
- 'spec/beaker/test_suite_spec.rb'

# Offense count: 121
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Enabled: false

# Offense count: 239
# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
RSpec/Eq:
Exclude:
- 'spec/beaker/logger_spec.rb'

# Offense count: 241
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 44
Expand Down Expand Up @@ -201,7 +213,7 @@ RSpec/MultipleDescribes:
RSpec/MultipleMemoizedHelpers:
Max: 18

# Offense count: 500
# Offense count: 502
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
# SupportedStyles: always, named_only
RSpec/NamedSubject:
Expand All @@ -218,6 +230,20 @@ RSpec/NoExpectationExample:
- 'spec/beaker/logger_spec.rb'
- 'spec/beaker/options/subcommand_options_parser_spec.rb'

# Offense count: 60
# This cop supports unsafe autocorrection (--autocorrect-all).
RSpec/ReceiveMessages:
Exclude:
- 'spec/beaker/cli_spec.rb'
- 'spec/beaker/command_spec.rb'
- 'spec/beaker/host_prebuilt_steps_spec.rb'
- 'spec/beaker/host_spec.rb'
- 'spec/beaker/options/parser_spec.rb'
- 'spec/beaker/shared/error_handler_spec.rb'
- 'spec/beaker/subcommand_spec.rb'
- 'spec/beaker/test_suite_spec.rb'
- 'spec/helpers.rb'

# Offense count: 7
RSpec/RepeatedDescription:
Exclude:
Expand All @@ -231,6 +257,26 @@ RSpec/RepeatedExample:
- 'spec/beaker/dsl/roles_spec.rb'
- 'spec/beaker/logger_spec.rb'

# Offense count: 13
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
# Include: **/*_spec.rb
RSpec/SpecFilePathFormat:
Exclude:
- '**/spec/routing/**/*'
- 'spec/beaker/dsl/assertions_spec.rb'
- 'spec/beaker/dsl/helpers/host_helpers_spec.rb'
- 'spec/beaker/dsl/helpers/test_helpers_spec.rb'
- 'spec/beaker/dsl/helpers/web_helpers_spec.rb'
- 'spec/beaker/dsl/outcomes_spec.rb'
- 'spec/beaker/dsl/roles_spec.rb'
- 'spec/beaker/dsl/structure_spec.rb'
- 'spec/beaker/dsl/wrappers_spec.rb'
- 'spec/beaker/host/mac/group_spec.rb'
- 'spec/beaker/host/mac/user_spec.rb'
- 'spec/beaker/host/pswindows/user_spec.rb'
- 'spec/beaker/host/windows/user_spec.rb'
- 'spec/beaker/host_prebuilt_steps_spec.rb'

# Offense count: 178
RSpec/SubjectStub:
Exclude:
Expand Down Expand Up @@ -283,7 +329,7 @@ Security/Open:
Exclude:
- 'lib/beaker/dsl/helpers/web_helpers.rb'

# Offense count: 104
# Offense count: 106
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
# URISchemes: http, https
Expand Down
2 changes: 1 addition & 1 deletion acceptance/tests/base/dsl/helpers/host_helpers/on_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,6 @@
tmp.blah
end
end
assert(Time.now > start + 1)
assert_operator(Time.now, :>, start + 1)
end
end
4 changes: 2 additions & 2 deletions acceptance/tests/base/dsl/platform_tag_confiner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
end

step "#{pstc_method_name} can remove hosts from a test, or be skipped if empty" do
assert hosts.length > 0, "#{pstc_method_name} did not have enough hosts to test"
assert_operator hosts.length, :>, 0, "#{pstc_method_name} did not have enough hosts to test"
previous_hosts = hosts.dup

options[:platform_tag_confines] = [
Expand All @@ -35,7 +35,7 @@
# is being raised confirms that a lower number of hosts are coming out of
# the confine (0) than came in (>0, according to our pre-condition assertion)
else
assert hosts.length < previous_hosts.length, "#{pstc_method_name} did not change hosts array"
assert_operator hosts.length, :<, previous_hosts.length, "#{pstc_method_name} did not change hosts array"
end

# cleanup
Expand Down
2 changes: 1 addition & 1 deletion beaker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'fakefs', '~> 2.4'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rspec', '~> 3.0'
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.0.0'
s.add_development_dependency 'voxpupuli-rubocop', '~> 2.3.0'

# Run time dependencies
s.add_runtime_dependency 'minitar', '~> 0.6'
Expand Down
8 changes: 4 additions & 4 deletions lib/beaker/shared/host_manager.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Beaker
module Shared
# Methods for managing Hosts.
#- selecting hosts by role (Symbol or String)
#- selecting hosts by name (String)
#- adding additional method definitions for selecting by role
#- executing blocks of code against selected sets of hosts
# - selecting hosts by role (Symbol or String)
# - selecting hosts by name (String)
# - adding additional method definitions for selecting by role
# - executing blocks of code against selected sets of hosts
module HostManager
# Find hosts from a given array of hosts that all have the desired role.
# @param [Array<Host>] hosts The hosts to examine
Expand Down
4 changes: 2 additions & 2 deletions lib/beaker/ssh_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ def connect options = {}
# Try each method in turn until we succeed
methods = @ssh_connection_preference.dup
while (not @ssh) && (not methods.empty?)
if instance_variable_get("@#{methods[0]}").nil?
if instance_variable_get(:"@#{methods[0]}").nil?
@logger.warn "Skipping #{methods[0]} method to ssh to host as its value is not set. Refer to https://github.com/puppetlabs/beaker/tree/master/docs/how_to/ssh_connection_preference.md to remove this warning"
elsif SUPPORTED_CONNECTION_METHODS.include?(methods[0])
@ssh = connect_block(instance_variable_get("@#{methods[0]}"), @user, @ssh_opts, options)
@ssh = connect_block(instance_variable_get(:"@#{methods[0]}"), @user, @ssh_opts, options)
else
@logger.warn "Beaker does not support #{methods[0]} to SSH to host, trying next available method."
@ssh_connection_preference.delete(methods[0])
Expand Down
22 changes: 11 additions & 11 deletions spec/beaker/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,9 @@ module Beaker

expect(cli).to receive(:run_suite).twice
expect { cli.execute! }.to raise_error
expect(cli.instance_variable_get(:@attribution)[:logger]).to be == 'runtime'
expect(cli.instance_variable_get(:@attribution)[:timestamp]).to be == 'runtime'
expect(cli.instance_variable_get(:@attribution)[:beaker_version]).to be == 'runtime'
expect(cli.instance_variable_get(:@attribution)[:logger]).to eq 'runtime'
expect(cli.instance_variable_get(:@attribution)[:timestamp]).to eq 'runtime'
expect(cli.instance_variable_get(:@attribution)[:beaker_version]).to eq 'runtime'
end

it 'continues testing after failed test if using slow fail_mode' do
Expand Down Expand Up @@ -362,10 +362,10 @@ module Beaker

preserved_file = cli.preserve_hosts_file
hosts_yaml = load_yaml_file(preserved_file)
expect(hosts_yaml['CONFIG'][:tests]).to be == []
expect(hosts_yaml['CONFIG'][:pre_suite]).to be == []
expect(hosts_yaml['CONFIG'][:post_suite]).to be == []
expect(hosts_yaml['CONFIG'][:pre_cleanup]).to be == []
expect(hosts_yaml['CONFIG'][:tests]).to eq []
expect(hosts_yaml['CONFIG'][:pre_suite]).to eq []
expect(hosts_yaml['CONFIG'][:post_suite]).to eq []
expect(hosts_yaml['CONFIG'][:pre_cleanup]).to eq []
end
end

Expand Down Expand Up @@ -541,31 +541,31 @@ module Beaker
command_correct = "p --log-level debug --hosts #{new_hosts_file} jam --jankies --flag-business"

answer = cli.build_hosts_preserved_reproducing_command(command_to_sub, new_hosts_file)
expect(answer).to be_start_with(command_correct)
expect(answer).to start_with(command_correct)
end

it 'doesn\'t replace an entry if no --hosts key is found' do
command_to_sub = 'p --log-level debug johnnypantaloons7 --jankies --flag-business'
command_correct = 'p --log-level debug johnnypantaloons7 --jankies --flag-business'

answer = cli.build_hosts_preserved_reproducing_command(command_to_sub, 'john/deer/plans.txt')
expect(answer).to be_start_with(command_correct)
expect(answer).to start_with(command_correct)
end

it 'removes any old --provision flags' do
command_to_sub = '--provision jam --provision --jankies --flag-business'
command_correct = 'jam --jankies --flag-business'

answer = cli.build_hosts_preserved_reproducing_command(command_to_sub, 'can/talk/to/pigs.yml')
expect(answer).to be_start_with(command_correct)
expect(answer).to start_with(command_correct)
end

it 'removes any old --no-provision flags' do
command_to_sub = 'jam --no-provision --jankoos --no-provision --flag-businesses'
command_correct = 'jam --jankoos --flag-businesses'

answer = cli.build_hosts_preserved_reproducing_command(command_to_sub, 'can/talk/to/bears.yml')
expect(answer).to be_start_with(command_correct)
expect(answer).to start_with(command_correct)
end
end
end
Expand Down
20 changes: 10 additions & 10 deletions spec/beaker/command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ module Beaker
@args = %w[to the baz]
@options = { :foo => 'bar' }

expect(cmd.options).to be == @options
expect(cmd.args).to be == @args
expect(cmd.command).to be == @command
expect(cmd.options).to eq @options
expect(cmd.args).to eq @args
expect(cmd.command).to eq @command

expect(cmd.args_string).to be == 'to the baz'
expect(cmd.options_string).to be == '--foo=bar'
expect(cmd.args_string).to eq 'to the baz'
expect(cmd.options_string).to eq '--foo=bar'
end

describe '#:prepend_cmds' do
Expand All @@ -35,7 +35,7 @@ module Beaker
allow(host).to receive(:prepend_commands).and_return('aloha!')
allow(host).to receive(:append_commands).and_return('')

expect(cmd.cmd_line(host)).to be == "aloha! /usr/bin/blah --foo=bar to the baz"
expect(cmd.cmd_line(host)).to eq "aloha! /usr/bin/blah --foo=bar to the baz"
end

it 'can handle no prepend_cmds' do
Expand All @@ -45,7 +45,7 @@ module Beaker
allow(host).to receive(:prepend_commands).and_return('')
allow(host).to receive(:append_commands).and_return('')

expect(cmd.cmd_line(host)).to be == "/usr/bin/blah --foo=bar to the baz"
expect(cmd.cmd_line(host)).to eq "/usr/bin/blah --foo=bar to the baz"
end
end

Expand All @@ -57,7 +57,7 @@ module Beaker
allow(host).to receive(:prepend_commands).and_return('aloha!')
allow(host).to receive(:append_commands).and_return('moo cow')

expect(cmd.cmd_line(host)).to be == "aloha! /usr/bin/blah --foo=bar to the baz moo cow"
expect(cmd.cmd_line(host)).to eq "aloha! /usr/bin/blah --foo=bar to the baz moo cow"
end

it 'can handle no append_cmds' do
Expand All @@ -67,7 +67,7 @@ module Beaker
allow(host).to receive(:prepend_commands).and_return('')
allow(host).to receive(:append_commands).and_return('')

expect(cmd.cmd_line(host)).to be == "/usr/bin/blah --foo=bar to the baz"
expect(cmd.cmd_line(host)).to eq "/usr/bin/blah --foo=bar to the baz"
end
end

Expand All @@ -85,7 +85,7 @@ module Beaker
describe '#args_string' do
it 'joins an array' do
subject.args = ['my/command and', nil, 'its args and opts']
expect(subject.args_string).to be == 'my/command and its args and opts'
expect(subject.args_string).to eq 'my/command and its args and opts'
end
end
end
Expand Down
22 changes: 11 additions & 11 deletions spec/beaker/dsl/helpers/host_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def logger
# This will only get hit if forking processes is supported and at least 2 items are being submitted to run in parallel
expect(InParallel::InParallelExecutor).to receive(:_execute_in_parallel).with(any_args).and_call_original.exactly(5).times
results = subject.on(hosts, command, { :run_in_parallel => true })
expect(results).to be == expected
expect(results).to eq expected
end

it 'delegates to itself for each host passed' do
Expand All @@ -99,7 +99,7 @@ def logger
end

results = subject.on(hosts, command)
expect(results).to be == expected
expect(results).to eq expected
end

context 'upon command completion' do
Expand All @@ -110,19 +110,19 @@ def logger
end

it 'returns the result of the action' do
expect(@res).to be == result
expect(@res).to eq result
end

it 'provides access to stdout' do
expect(@res.stdout).to be == 'stdout'
expect(@res.stdout).to eq 'stdout'
end

it 'provides access to stderr' do
expect(@res.stderr).to be == 'stderr'
expect(@res.stderr).to eq 'stderr'
end

it 'provides access to exit_code' do
expect(@res.exit_code).to be == 0
expect(@res.exit_code).to eq 0
end
end

Expand All @@ -141,19 +141,19 @@ def logger

it 'provides access to stdout' do
subject.on host, command do |containing_class|
expect(containing_class.stdout).to be == 'stdout'
expect(containing_class.stdout).to eq 'stdout'
end
end

it 'provides access to stderr' do
subject.on host, command do |containing_class|
expect(containing_class.stderr).to be == 'stderr'
expect(containing_class.stderr).to eq 'stderr'
end
end

it 'provides access to exit_code' do
subject.on host, command do |containing_class|
expect(containing_class.exit_code).to be == 0
expect(containing_class.exit_code).to eq 0
end
end
end
Expand Down Expand Up @@ -203,7 +203,7 @@ def logger
expect { subject.retry_on(host, command, opts) }.to raise_error(RuntimeError)
end

it 'will return success correctly if it succeeds the first time' do
it 'returns success correctly if it succeeds the first time' do
result.stdout = 'stdout'
result.stderr = 'stderr'
result.exit_code = 0
Expand All @@ -220,7 +220,7 @@ def logger
expect(result_given.exit_code).to be === 0
end

it 'will return success correctly if it succeeds after failing a few times' do
it 'returns success correctly if it succeeds after failing a few times' do
result.stdout = 'stdout'
result.stderr = 'stderr'

Expand Down
Loading

0 comments on commit c32b6d2

Please sign in to comment.