Skip to content

Commit

Permalink
rubocop: Fix Style/MethodCallWithoutArgsParentheses
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Mar 24, 2023
1 parent cd5a3ff commit 709c227
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
test_name "dsl::helpers::host_helpers #backup_the_file" do
step "#backup_the_file CURRENTLY will return nil if the file does not exist in the source directory" do
# NOTE: would expect this to fail with Beaker::Host::CommandFailure
remote_source = default.tmpdir()
remote_destination = default.tmpdir()
remote_source = default.tmpdir
remote_destination = default.tmpdir
result = backup_the_file default, remote_source, remote_destination
assert_nil result
end

step "#backup_the_file will fail if the destination directory does not exist" do
remote_source = default.tmpdir()
remote_source = default.tmpdir
create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")

assert_raises Beaker::Host::CommandFailure do
Expand All @@ -19,10 +19,10 @@
end

step "#backup_the_file copies `puppet.conf` from the source to the destination directory" do
remote_source = default.tmpdir()
remote_source = default.tmpdir
_remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")

remote_destination = default.tmpdir()
remote_destination = default.tmpdir
remote_destination_filename = File.join(remote_destination, "puppet.conf.bak")

result = backup_the_file default, remote_source, remote_destination
Expand All @@ -33,10 +33,10 @@
end

step "#backup_the_file copies a named file from the source to the destination directory" do
remote_source = default.tmpdir()
remote_source = default.tmpdir
_remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")

remote_destination = default.tmpdir()
remote_destination = default.tmpdir
remote_destination_filename = File.join(remote_destination, "testfile.txt.bak")

result = backup_the_file default, remote_source, remote_destination, "testfile.txt"
Expand All @@ -47,9 +47,9 @@
end

step "#backup_the_file CURRENTLY will fail if given a hosts array" do
remote_source = default.tmpdir()
remote_source = default.tmpdir
create_remote_file_from_fixture("simple_text_file", default, remote_source, "testfile.txt")
remote_destination = default.tmpdir()
remote_destination = default.tmpdir

assert_raises NoMethodError do
backup_the_file hosts, remote_source, remote_destination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def host_local_url(host, path)
end

step "#curl_on can retrieve the contents of a URL, using standard curl options" do
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")
remote_targetfilename = File.join remote_tmpdir, "outfile.txt"

Expand All @@ -29,7 +29,7 @@ def host_local_url(host, path)
end

step "#curl_on can retrieve the contents of a URL, when given a hosts array" do
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
on hosts, "mkdir -p #{remote_tmpdir}"

remote_filename = contents = nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
step "#retry_on CURRENTLY fails with a RuntimeError if command does not pass after all retries" do
# NOTE: would have expected this to fail with Beaker::Hosts::CommandFailure

remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
remote_script_file = File.join(remote_tmpdir, "test.sh")
create_remote_file_from_fixture("retry_script", default, remote_tmpdir, "test.sh")

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

step "#retry_on succeeds if command passes before retries are exhausted" do
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
remote_script_file = File.join(remote_tmpdir, "test.sh")
create_remote_file_from_fixture("retry_script", default, remote_tmpdir, "test.sh")

Expand All @@ -27,7 +27,7 @@
# NOTE: would expect this to work across hosts, or be better documented and
# to raise Beaker::Host::CommandFailure

remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
remote_script_file = File.join(remote_tmpdir, "test.sh")

hosts.each do |host|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def rsync_to_with_backups hosts, local_filename, remote_dir
step "#rsync_to CURRENTLY fails on windows systems" do
Dir.mktmpdir do |local_dir|
local_filename, _contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir

assert_raises Beaker::Host::CommandFailure do
rsync_to default, local_filename, remote_tmpdir
Expand All @@ -54,7 +54,7 @@ def rsync_to_with_backups hosts, local_filename, remote_dir
confine :except, :hypervisor => 'docker'

step "#rsync_to fails if the local file cannot be found" do
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
assert_raises IOError do
rsync_to default, "/non/existent/file.txt", remote_tmpdir
end
Expand Down Expand Up @@ -116,7 +116,7 @@ def rsync_to_with_backups hosts, local_filename, remote_dir
step "#rsync_to creates the file on the remote system" do
Dir.mktmpdir do |local_dir|
local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
remote_filename = File.join(remote_tmpdir, "testfile.txt")

result = rsync_to_with_backups default, local_filename, remote_tmpdir
Expand All @@ -138,7 +138,7 @@ def rsync_to_with_backups hosts, local_filename, remote_dir
step "#rsync_to creates the file on all remote systems when a host array is provided" do
Dir.mktmpdir do |local_dir|
local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
on hosts, "mkdir -p #{remote_tmpdir}"
remote_filename = File.join(remote_tmpdir, "testfile.txt")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
test_name "dsl::helpers::host_helpers #scp_from" do
if test_scp_error_on_close?
step "#scp_from fails if the local path cannot be found" do
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
remote_filename, _contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")

assert_raises Beaker::Host::CommandFailure do
Expand All @@ -22,7 +22,7 @@

step "#scp_from creates the file on the local system" do
Dir.mktmpdir do |local_dir|
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
remote_filename, contents = create_remote_file_from_fixture("simple_text_file", default, remote_tmpdir, "testfile.txt")

scp_from default, remote_filename, local_dir
Expand All @@ -37,7 +37,7 @@
# file repeatedly to generate an error

Dir.mktmpdir do |local_dir|
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
remote_filename = File.join(remote_tmpdir, "testfile.txt")
on hosts, "mkdir -p #{remote_tmpdir}"
on hosts, %{echo "${RANDOM}:${RANDOM}:${RANDOM}" > #{remote_filename}}
Expand Down
6 changes: 3 additions & 3 deletions acceptance/tests/base/dsl/helpers/host_helpers/scp_to_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

test_name "dsl::helpers::host_helpers #scp_to" do
step "#scp_to fails if the local file cannot be found" do
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
assert_raises IOError do
scp_to default, "/non/existent/file.txt", remote_tmpdir
end
Expand All @@ -24,7 +24,7 @@
step "#scp_to creates the file on the remote system" do
Dir.mktmpdir do |local_dir|
local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir

scp_to default, local_filename, remote_tmpdir

Expand All @@ -38,7 +38,7 @@
Dir.mktmpdir do |local_dir|
local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")

remote_tmpdir = default.tmpdir()
remote_tmpdir = default.tmpdir
on hosts, "mkdir -p #{remote_tmpdir}"
remote_filename = File.join(remote_tmpdir, "testfile.txt")

Expand Down
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 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 hosts.length < previous_hosts.length, "#{pstc_method_name} did not change hosts array"
end

# cleanup
Expand Down
2 changes: 1 addition & 1 deletion lib/beaker/host/aix/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ def ssh_service_restart
# (from {#ssh_service_restart}).
def ssh_permit_user_environment
exec(Beaker::Command.new("echo '\nPermitUserEnvironment yes' >> /etc/ssh/sshd_config"))
ssh_service_restart()
ssh_service_restart
end
end
2 changes: 1 addition & 1 deletion lib/beaker/host/mac/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def ssh_permit_user_environment
ssh_config_file = '/private/etc/ssh/sshd_config' if /^osx-/.match?(self['platform'])

exec(Beaker::Command.new("echo '\nPermitUserEnvironment yes' >> #{ssh_config_file}"))
ssh_service_restart()
ssh_service_restart
end

#  Checks if selinux is enabled
Expand Down
6 changes: 3 additions & 3 deletions lib/beaker/host/pswindows/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module PSWindows::File

def tmpfile(_name = '')
result = exec(powershell('[System.IO.Path]::GetTempFileName()'))
result.stdout.chomp()
result.stdout.chomp
end

def tmpdir(name = '')
tmp_path = exec(powershell('[System.IO.Path]::GetTempPath()')).stdout.chomp()
tmp_path = exec(powershell('[System.IO.Path]::GetTempPath()')).stdout.chomp

name = exec(powershell('[System.IO.Path]::GetRandomFileName()')).stdout.chomp() if name == ''
name = exec(powershell('[System.IO.Path]::GetRandomFileName()')).stdout.chomp if name == ''
exec(powershell("New-Item -Path '#{tmp_path}' -Force -Name '#{name}' -ItemType 'directory'"))
File.join(tmp_path, name)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/beaker/host/unix/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def ssh_service_restart
def ssh_permit_user_environment
case self['platform']
when /debian|ubuntu|cumulus|huaweios|archlinux|el-|centos|fedora|redhat|oracle|scientific|eos|opensuse|sles|solaris/
directory = tmpdir()
directory = tmpdir
exec(Beaker::Command.new("echo 'PermitUserEnvironment yes' | cat - /etc/ssh/sshd_config > #{directory}/sshd_config.permit"))
exec(Beaker::Command.new("mv #{directory}/sshd_config.permit /etc/ssh/sshd_config"))
exec(Beaker::Command.new("echo '' >/etc/environment")) if /ubuntu-2(0|2).04/.match?(self['platform'])
Expand All @@ -313,7 +313,7 @@ def ssh_permit_user_environment
raise ArgumentError, "Unsupported Platform: '#{self['platform']}'"
end

ssh_service_restart()
ssh_service_restart
end

# Construct the environment string for this command
Expand Down
2 changes: 1 addition & 1 deletion lib/beaker/host/windows/exec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def ssh_service_restart
# (from {#ssh_service_restart}).
def ssh_permit_user_environment
exec(Beaker::Command.new("echo '\nPermitUserEnvironment yes' >> /etc/sshd_config"))
ssh_service_restart()
ssh_service_restart
end

# Gets the specific prepend commands as needed for this host
Expand Down
2 changes: 1 addition & 1 deletion spec/beaker/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ module Beaker

context 'execute!' do
before do
stub_const("Beaker::Logger", double().as_null_object)
stub_const("Beaker::Logger", double.as_null_object)
File.open("sample.cfg", "w+") do |file|
file.write("HOSTS:\n")
file.write(" myhost:\n")
Expand Down
20 changes: 10 additions & 10 deletions spec/beaker/dsl/test_tagging_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ class ClassMixedWithDSLStructure
}]

internal_hash = confiner.instance_variable_get(:@tag_confine_details_hash)
expect(internal_hash.keys()).to include('tag1')
expect(internal_hash.keys()).to include('tag2')
expect(internal_hash.keys().length()).to be === 2
expect(internal_hash.keys).to include('tag1')
expect(internal_hash.keys).to include('tag2')
expect(internal_hash.keys.length).to be === 2

tag_reason_hash.each do |tag, reason|
tag_array = internal_hash[tag]
expect(tag_array.length()).to be === 1
expect(tag_array.length).to be === 1
tag_hash = tag_array[0]
expect(tag_hash[:platform_regex]).to eql(platform_regex)
expect(tag_hash[:log_message]).to match(/#{reason}/)
Expand All @@ -181,13 +181,13 @@ class ClassMixedWithDSLStructure
]

internal_hash = confiner.instance_variable_get(:@tag_confine_details_hash)
expect(internal_hash.keys()).to include('tag1')
expect(internal_hash.keys()).to include('tag2')
expect(internal_hash.keys()).to include('tag3')
expect(internal_hash.keys().length()).to be === 3
expect(internal_hash.keys).to include('tag1')
expect(internal_hash.keys).to include('tag2')
expect(internal_hash.keys).to include('tag3')
expect(internal_hash.keys.length).to be === 3

shared_tag_array = internal_hash['tag1']
expect(shared_tag_array.length()).to be === 2
expect(shared_tag_array.length).to be === 2

platform_el_found = false
platform_cisco_found = false
Expand Down Expand Up @@ -237,7 +237,7 @@ class ClassMixedWithDSLStructure
key_combos_to_test << ['tag0', 'tag2']
key_combos_to_test << ['tag1', 'tag4']
key_combos_to_test << ['tag2', 'tag3', 'tag4']
key_combos_to_test << fake_confine_details_hash.keys()
key_combos_to_test << fake_confine_details_hash.keys

before do
confiner.instance_variable_set(
Expand Down
2 changes: 1 addition & 1 deletion spec/beaker/host_prebuilt_steps_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe Beaker do
let(:options) { make_opts.merge({ 'logger' => double().as_null_object }) }
let(:options) { make_opts.merge({ 'logger' => double.as_null_object }) }
let(:ntpserver_set) { "ntp_server_set" }
let(:options_ntp) { make_opts.merge({ 'ntp_server' => ntpserver_set }) }
let(:ntpserver) { Beaker::HostPrebuiltSteps::NTPSERVER }
Expand Down
14 changes: 7 additions & 7 deletions spec/beaker/hypervisor/hypervisor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module Beaker

it "includes custom hypervisor and call set_ssh_connection_preference" do
allow(hypervisor).to receive(:set_ssh_connection_preference).with([], hypervisor)
expect { hypervisor.create('custom_hypervisor', [], make_opts()) }.to raise_error(LoadError, "cannot load such file -- beaker/hypervisor/custom_hypervisor")
expect { hypervisor.create('custom_hypervisor', [], make_opts) }.to raise_error(LoadError, "cannot load such file -- beaker/hypervisor/custom_hypervisor")
end

it "sets ssh connection preference if connection_preference method is not overwritten" do
hypervisor.create('none', hosts, make_opts())
hypervisor.create('none', hosts, make_opts)
expect(hosts[0][:ssh_connection_preference]).to eq([:ip, :vmhostname, :hostname])
end

Expand All @@ -31,15 +31,15 @@ module Beaker

it "gives highest precedence to preference specified in host file followed by hypervisor" do
hosts[0].options[:ssh_preference] = [:set, :in, :hostfile]
hypervisor.create('none', hosts, make_opts())
hypervisor.create('none', hosts, make_opts)
allow(hypervisor).to receive(:connection_preference).and_return([:hypervisor, :pref])
hypervisor.set_ssh_connection_preference(hosts, hypervisor)
expect(hosts[0][:ssh_connection_preference]).to eq([:set, :in, :hostfile, :hypervisor, :pref, :ip, :vmhostname, :hostname])
end
end

describe "#configure" do
let(:options) { make_opts.merge({ 'logger' => double().as_null_object }) }
let(:options) { make_opts.merge({ 'logger' => double.as_null_object }) }
let(:hypervisor) { described_class.new(hosts, options) }

context 'if :timesync option set true on host' do
Expand All @@ -51,7 +51,7 @@ module Beaker
end

it 'catches signal exceptions and returns stack trace' do
logger = double()
logger = double
hosts[0].options[:timesync] = true
allow(logger).to receive(:error)
allow(logger).to receive(:pretty_backtrace).and_return("multiline\nstring")
Expand Down Expand Up @@ -131,8 +131,8 @@ module Beaker
it "generates hostname with prefix" do
prefix = "testing-prefix-to-test-"
options[:host_name_prefix] = prefix
expect(hypervisor.generate_host_name().start_with?(prefix)).to be true
expect(hypervisor.generate_host_name().length - prefix.length >= 15).to be true
expect(hypervisor.generate_host_name.start_with?(prefix)).to be true
expect(hypervisor.generate_host_name.length - prefix.length >= 15).to be true
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/beaker/network_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Beaker
end
let(:options) do
make_opts.merge({
'logger' => double().as_null_object,
'logger' => double.as_null_object,
:logger_sut => mock_provisioning_logger,
:log_prefix => @log_prefix,
:hosts_file => @hosts_file,
Expand Down
Loading

0 comments on commit 709c227

Please sign in to comment.