Skip to content

Commit

Permalink
rubocop: Fix Style/StringLiterals
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Mar 24, 2023
1 parent d41637c commit d6df4ec
Show file tree
Hide file tree
Showing 127 changed files with 1,395 additions and 1,395 deletions.
30 changes: 15 additions & 15 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def beaker_test(mode = :base, options = {})
preserved_hosts_mode = options[:hosts] == HOSTS_PRESERVED
final_options = HarnessOptions.final_options(mode, options)

options_opt = ""
options_opt = ''
# preserved hosts can not be used with an options file (BKR-670)
# one can still use OPTIONS

Expand All @@ -109,14 +109,14 @@ def beaker_test(mode = :base, options = {})
end

tests = ENV['TESTS'] || ENV.fetch('TEST', nil)
tests_opt = ""
tests_opt = ''
tests_opt = "--tests=#{tests}" if tests

overriding_options = ENV['OPTIONS'].to_s

args = [options_opt, hosts_opt(preserved_hosts_mode), tests_opt, *overriding_options.split(' ')].compact

sh("beaker", *args)
sh('beaker', *args)
end

namespace :test do
Expand All @@ -135,7 +135,7 @@ namespace :test do
Dir.chdir(__dir__) do
exit_status = 1
output = ''
Open3.popen3("bundle exec rspec") do |_stdin, stdout, _stderr, wait_thr|
Open3.popen3('bundle exec rspec') do |_stdin, stdout, _stderr, wait_thr|
while (line = stdout.gets)
puts line
end
Expand All @@ -146,7 +146,7 @@ namespace :test do
end
if exit_status != /0/
# check for deprecation warnings
fail "DEPRECATION WARNINGS in spec generation, please fix!" if output.include?('Deprecation Warnings')
fail 'DEPRECATION WARNINGS in spec generation, please fix!' if output.include?('Deprecation Warnings')
end
end
end
Expand Down Expand Up @@ -200,7 +200,7 @@ namespace :history do
Dir.chdir(__dir__) do
output = `bundle exec ruby history.rb .`
puts output
raise "History generation failed" if !output.include?('success')
raise 'History generation failed' if !output.include?('success')
end
end
end
Expand Down Expand Up @@ -247,15 +247,15 @@ namespace :docs do
Dir.chdir(__dir__) do
output = `bundle exec yard doc -o #{DOCS_DIR}`
puts output
fail "Errors/Warnings during yard documentation generation" if /\[warn\]|\[error\]/.match?(output)
fail 'Errors/Warnings during yard documentation generation' if /\[warn\]|\[error\]/.match?(output)
end
end

desc 'Run the documentation server in the background, alias `bg`'
task :background => 'docs:clear' do
yes, output = running?(DOCS_DAEMON)
if yes
puts "Not starting a new YARD Server..."
puts 'Not starting a new YARD Server...'
puts "Found one running with pid #{pid_from(output)}."
else
Dir.chdir(__dir__) do
Expand All @@ -273,32 +273,32 @@ namespace :docs do
pid = pid_from(output)
puts "Found a YARD Server running with pid #{pid}"
else
puts "Could not find a running YARD Server."
puts 'Could not find a running YARD Server.'
end
end

desc "Stop a running YARD Server"
desc 'Stop a running YARD Server'
task :stop do
yes, output = running?(DOCS_DAEMON)
if yes
pid = pid_from(output)
puts "Found a YARD Server running with pid #{pid}"
`kill #{pid}`
puts "Stopping..."
puts 'Stopping...'
yes, _output = running?(DOCS_DAEMON)
if yes
`kill -9 #{pid}`
yes, _output = running?(DOCS_DAEMON)
if yes
puts "Could not Stop Server!"
puts 'Could not Stop Server!'
else
puts "Server stopped."
puts 'Server stopped.'
end
else
puts "Server stopped."
puts 'Server stopped.'
end
else
puts "Could not find a running YARD Server"
puts 'Could not find a running YARD Server'
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion acceptance/config/acceptance-options.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
:load_path => File.join('acceptance', 'lib'),
:ssh => {
:keys => ["id_rsa_acceptance", "#{ENV.fetch('HOME', nil)}/.ssh/id_rsa-acceptance"],
:keys => ['id_rsa_acceptance', "#{ENV.fetch('HOME', nil)}/.ssh/id_rsa-acceptance"],
},
}
4 changes: 2 additions & 2 deletions acceptance/fixtures/module/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send(:disable_80chars)
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp']

desc "Validate manifests, templates, and ruby files"
desc 'Validate manifests, templates, and ruby files'
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
Expand Down
12 changes: 6 additions & 6 deletions acceptance/fixtures/module/spec/acceptance/demo_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
require 'spec_helper_acceptance'

describe "my tests" do
describe 'my tests' do
# an example using the beaker DSL
# use http://www.rubydoc.info/github/puppetlabs/beaker/Beaker/DSL
it "says hello!" do
it 'says hello!' do
result = shell('echo hello')
expect(result.stdout).to match(/hello/)
end
Expand All @@ -14,14 +14,14 @@
it { is_expected.to be_installed }
end

it "can create and confirm a file" do
it 'can create and confirm a file' do
shell('rm -f demo.txt')
create_remote_file(default, 'demo.txt', 'foo\nfoo\nfoo\n')
shell('grep foo demo.txt')
shell('grep bar demo.txt', :acceptable_exit_codes => [1])
end

it "is able to apply manifests" do
it 'is able to apply manifests' do
manifest_1 = "user {'foo':
ensure => present,}"
manifest_2 = "user {'foo':
Expand All @@ -45,8 +45,8 @@
it { is_expected.not_to exist }
end

context "can use both serverspec and Beaker DSL" do
it "can create a file" do
context 'can use both serverspec and Beaker DSL' do
it 'can create a file' do
shell('rm -f /tmp/demo.txt')
manifest = "file {'demofile':
path => '/tmp/demo.txt',
Expand Down
10 changes: 5 additions & 5 deletions acceptance/lib/helpers/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# TODO: fix via: https://tickets.puppetlabs.com/browse/BKR-464
def test_scp_error_on_close?
!!ENV["BEAKER_TEST_SCP_ERROR_ON_CLOSE"]
!!ENV['BEAKER_TEST_SCP_ERROR_ON_CLOSE']
end

# Returns the absolute path where file fixtures are located.
Expand Down Expand Up @@ -38,7 +38,7 @@ def create_local_file_from_fixture(fixture, local_path, filename, perms = nil)
full_filename = File.join(local_path, filename)
contents = fixture_contents fixture

File.open(full_filename, "w") do |local_file|
File.open(full_filename, 'w') do |local_file|
local_file.puts contents
end
FileUtils.chmod perms, full_filename if perms
Expand Down Expand Up @@ -66,15 +66,15 @@ def create_local_file_from_fixture(fixture, local_path, filename, perms = nil)
#
# Returns the value of the yielded block.
def fails_intermittently(issue_link, args = {})
raise ArgumentError, "provide a Jira ticket link" unless issue_link
raise ArgumentError, "a block is required" unless block_given?
raise ArgumentError, 'provide a Jira ticket link' unless issue_link
raise ArgumentError, 'a block is required' unless block_given?

yield
rescue MiniTest::Assertion, StandardError, SignalException # we have a test failure!
STDERR.puts "\n\nIntermittent test failure! See: #{issue_link}"

if args.empty?
STDERR.puts "No further debugging information available."
STDERR.puts 'No further debugging information available.'
else
STDERR.puts "Debugging information:\n"
args.keys.sort.each do |key|
Expand Down
6 changes: 3 additions & 3 deletions acceptance/pre_suite/subcommands/05_install_ruby.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ruby_version, ruby_source = ENV.fetch('RUBY_VER', nil), "job parameter"
ruby_version, ruby_source = ENV.fetch('RUBY_VER', nil), 'job parameter'
unless ruby_version
ruby_version = "2.4.1"
ruby_source = "default"
ruby_version = '2.4.1'
ruby_source = 'default'
end
test_name "Install and configure Ruby #{ruby_version} (from #{ruby_source}) on the SUT" do
step 'Ensure that the default system is an el-based system' do
Expand Down
2 changes: 1 addition & 1 deletion acceptance/pre_suite/subcommands/08_install_beaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

step 'Detect if checking out branch for testing and checkout' do
if ENV['BEAKER_PULL_ID']
logger.notify "Pull Request detected, checking out PR branch"
logger.notify 'Pull Request detected, checking out PR branch'
on(default, 'cd /opt/beaker/;git -c core.askpass=true fetch --tags --progress https://github.com/puppetlabs/beaker.git +refs/pull/*:refs/remotes/origin/pr/*')
on(default, "cd /opt/beaker/;git merge origin/pr/#{ENV['BEAKER_PULL_ID']}/head --no-edit")
else
Expand Down
12 changes: 6 additions & 6 deletions acceptance/tests/base/dsl/helpers/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

require 'helpers/test_helper'

test_name "dsl::helpers::host_helpers test configuration validation" do
step "Validate hosts configuration" do
test_name 'dsl::helpers::host_helpers test configuration validation' do
step 'Validate hosts configuration' do
assert (hosts.size > 1),
"dsl::helpers::host_helpers acceptance tests require at least two hosts"
'dsl::helpers::host_helpers acceptance tests require at least two hosts'

agents = select_hosts(:roles => "agent")
agents = select_hosts(:roles => 'agent')
assert (agents.size > 1),
"dsl::helpers::host_helpers acceptance tests require at least two hosts with the :agent role"
'dsl::helpers::host_helpers acceptance tests require at least two hosts with the :agent role'

assert default,
"dsl::helpers::host_helpers acceptance tests require a default host"
'dsl::helpers::host_helpers acceptance tests require a default host'
end
end
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
require "helpers/test_helper"
require 'helpers/test_helper'

test_name "dsl::helpers::host_helpers #add_system32_hosts_entry" do
test_name 'dsl::helpers::host_helpers #add_system32_hosts_entry' do
confine_block :to, :platform => /windows/ do
step "#add_system32_hosts_entry fails when run on a non-powershell platform" do
step '#add_system32_hosts_entry fails when run on a non-powershell platform' do
# NOTE: would expect this to be better documented.
if default.is_powershell?
logger.info "Skipping failure test on powershell platforms..."
logger.info 'Skipping failure test on powershell platforms...'
else
assert_raises RuntimeError do
add_system32_hosts_entry default, { :ip => '123.45.67.89', :name => 'beaker.puppetlabs.com' }
end
end
end

step "#add_system32_hosts_entry, when run on a powershell platform, adds a host entry to system32 etc\\hosts" do
step '#add_system32_hosts_entry, when run on a powershell platform, adds a host entry to system32 etc\\hosts' do
if default.is_powershell?
add_system32_hosts_entry default, { :ip => '123.45.67.89', :name => 'beaker.puppetlabs.com' }

# TODO: how do we assert, via powershell, that the entry was added?
# NOTE: see: https://github.com/puppetlabs/beaker/commit/685628f4babebe9cb4663418da6a8ff528dd32da#commitcomment-12957573

else
logger.info "Skipping test on non-powershell platforms..."
logger.info 'Skipping test on non-powershell platforms...'
end
end

step "#add_system32_hosts_entry CURRENTLY fails with a TypeError when given a hosts array" do
step '#add_system32_hosts_entry CURRENTLY fails with a TypeError when given a hosts array' do
# NOTE: would expect this to fail with Beaker::Host::CommandFailure
assert_raises NoMethodError do
add_system32_hosts_entry hosts, { :ip => '123.45.67.89', :name => 'beaker.puppetlabs.com' }
Expand All @@ -34,7 +34,7 @@
end

confine_block :except, :platform => /windows/ do
step "#add_system32_hosts_entry CURRENTLY fails with RuntimeError when run on a non-windows platform" do
step '#add_system32_hosts_entry CURRENTLY fails with RuntimeError when run on a non-windows platform' do
# NOTE: would expect this to behave the same way it does on a windows
# non-powershell platform (raises Beaker::Host::CommandFailure), or
# as requested in the original PR:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "helpers/test_helper"
require 'helpers/test_helper'

test_name "dsl::helpers::host_helpers #archive_file_from" do
step "archiveroot parameter defaults to `archive/sut-files`" do
test_name 'dsl::helpers::host_helpers #archive_file_from' do
step 'archiveroot parameter defaults to `archive/sut-files`' do
# Create a remote file to archive
filepath = default.tmpfile('archive-file-test')
create_remote_file(default, filepath, 'contents ignored')
Expand All @@ -18,17 +18,17 @@
assert_equal(true, Dir.exist?('archive/sut-files'))
end

step "fails archive_file_from when from_path is non-existant" do
step 'fails archive_file_from when from_path is non-existant' do
# beaker-docker can't deal with closing the connection
confine :except, :hypervisor => 'docker'

filepath = "foo-filepath-should-not-exist"
filepath = 'foo-filepath-should-not-exist'
assert_raises IOError do
archive_file_from(default, filepath)
end
end

step "archive is copied to local <archiveroot>/<hostname>/<filepath> directory" do
step 'archive is copied to local <archiveroot>/<hostname>/<filepath> directory' do
# Create a remote file to archive
filepath = default.tmpfile('archive-file-test')
create_remote_file(default, filepath, 'number of the beast')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
require "helpers/test_helper"
require 'helpers/test_helper'

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
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
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
step '#backup_the_file will fail if the destination directory does not exist' do
remote_source = default.tmpdir
create_remote_file_from_fixture("simple_text_file", default, remote_source, "puppet.conf")
create_remote_file_from_fixture('simple_text_file', default, remote_source, 'puppet.conf')

assert_raises Beaker::Host::CommandFailure do
backup_the_file default, remote_source, "/non/existent/"
backup_the_file default, remote_source, '/non/existent/'
end
end

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

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

result = backup_the_file default, remote_source, remote_destination

Expand All @@ -32,23 +32,23 @@
assert_equal contents, remote_contents
end

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

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

result = backup_the_file default, remote_source, remote_destination, "testfile.txt"
result = backup_the_file default, remote_source, remote_destination, 'testfile.txt'

assert_equal remote_destination_filename, result
remote_contents = on(default, "cat #{remote_destination_filename}").stdout
assert_equal contents, remote_contents
end

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

assert_raises NoMethodError do
Expand Down
Loading

0 comments on commit d6df4ec

Please sign in to comment.