Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 1 addition & 60 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2023-03-17 09:38:53 UTC using RuboCop version 1.12.1.
# on 2023-03-17 12:20:43 UTC using RuboCop version 1.12.1.
# 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
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
Lint/IneffectiveAccessModifier:
Exclude:
- 'lib/beaker-rspec/helpers/serverspec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'lib/beaker-rspec/spec_helper.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
Lint/UnusedMethodArgument:
Exclude:
- 'lib/beaker-rspec/helpers/serverspec.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'lib/beaker-rspec/helpers/serverspec.rb'

# Offense count: 3
Lint/UselessAssignment:
Exclude:
Expand All @@ -56,24 +30,6 @@ Naming/MethodParameterName:
Exclude:
- 'lib/beaker-rspec/beaker_shim.rb'

# Offense count: 4
# Cop supports --auto-correct.
Performance/RegexpMatch:
Exclude:
- 'lib/beaker-rspec/helpers/serverspec.rb'

# Offense count: 3
# Cop supports --auto-correct.
Performance/StringIdentifierArgument:
Exclude:
- 'lib/beaker-rspec/helpers/serverspec.rb'

# Offense count: 3
# Cop supports --auto-correct.
Performance/StringInclude:
Exclude:
- 'lib/beaker-rspec/helpers/serverspec.rb'

# Offense count: 3
# Configuration parameters: Prefixes.
# Prefixes: when, with, without
Expand All @@ -86,18 +42,3 @@ RSpec/ContextWording:
RSpec/DescribeClass:
Exclude:
- 'spec/acceptance/example_spec.rb'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: .
# SupportedStyles: is_expected, should
RSpec/ImplicitExpect:
EnforcedStyle: should

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Exclude:
- 'lib/beaker-rspec/helpers/serverspec.rb'
21 changes: 10 additions & 11 deletions lib/beaker-rspec/helpers/serverspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def detect_os
return Specinfra.configuration.os if Specinfra.configuration.os
backend = Specinfra.backend
node = get_working_node
if node['platform'] =~ /windows/
if node['platform'].include?('windows')
Comment thread
bastelfreak marked this conversation as resolved.
return {:family => 'windows'}
end
Specinfra::Helper::DetectOs.subclasses.each do |c|
Expand All @@ -103,9 +103,9 @@ def get_windows_cmd(meth, *args)
method += "_#{subaction}" if subaction

common_class = Specinfra::Command
base_class = common_class.const_get('Base')
os_class = common_class.const_get('Windows')
version_class = os_class.const_get('Base')
base_class = common_class.const_get(:Base)
os_class = common_class.const_get(:Windows)
version_class = os_class.const_get(:Base)
command_class = version_class.const_get(resource_type.to_camel_case)

command_class = command_class.create
Expand All @@ -126,7 +126,7 @@ class Runner
def self.method_missing(meth, *args)
backend = Specinfra.backend
node = get_working_node
if node['platform'] !~ /windows/
if !node['platform'].include?('windows')
processor = Specinfra::Processor
if processor.respond_to?(meth)
processor.send(meth, *args)
Expand All @@ -144,14 +144,13 @@ def self.method_missing(meth, *args)
end
end

private

def self.run(meth, *args)
backend = Specinfra.backend
cmd = Specinfra.command.get(meth, *args)
backend = Specinfra.backend
ret = backend.run_command(cmd)
if meth.to_s =~ /^check/
if meth.to_s.start_with?('check')
ret.success?
else
ret
Expand Down Expand Up @@ -189,7 +188,7 @@ def ssh_exec!(node, command)
{
:exit_status => r.exit_code,
:stdout => r.stdout,
:stderr => r.stderr
:stderr => r.stderr,
}
end

Expand All @@ -201,7 +200,7 @@ module Specinfra::Backend
class BeakerDispatch < BeakerBase

def dispatch_method(meth, *args)
if get_working_node['platform'] =~ /windows/
if get_working_node['platform'].include?('windows')
cygwin_backend.send(meth, *args)
else
exec_backend.send(meth, *args)
Expand Down Expand Up @@ -232,7 +231,7 @@ class BeakerCygwin < BeakerBase
# @param [String] cmd The serverspec command to executed
# @param [Hash] opt No currently supported options
# @return [Hash] Returns a hash containing :exit_status, :stdout and :stderr
def run_command(cmd, opt = {})
def run_command(cmd, _opt = {})
node = get_working_node
script = create_script(cmd)
#when node is not cygwin rm -rf will fail so lets use native del instead
Expand Down Expand Up @@ -269,7 +268,7 @@ class BeakerExec < BeakerBase
# @param [String] cmd The serverspec command to executed
# @param [Hash] opt No currently supported options
# @return [Hash] Returns a hash containing :exit_status, :stdout and :stderr
def run_command(cmd, opt = {})
def run_command(cmd, _opt = {})
node = get_working_node
cmd = build_command(cmd)
cmd = add_pre_command(cmd)
Expand Down
2 changes: 1 addition & 1 deletion lib/beaker-rspec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
:debug => ENV['BEAKER_debug'] || ENV['RS_DEBUG'],
:destroy => ENV['BEAKER_destroy'] || ENV['RS_DESTROY'],
:optionsfile => ENV['BEAKER_options_file'] || ENV['RS_OPTIONS_FILE'],
}.delete_if {|key, value| value.nil?}
}.delete_if {|_key, value| value.nil?}
#combine defaults and env_vars to determine overall options
options = defaults.merge(env_vars)

Expand Down
10 changes: 5 additions & 5 deletions spec/acceptance/example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'ssh'
end
describe service(sshd), :node => node do
it { should be_running }
it { is_expected.to be_running }
end

usr = case node['platform']
Expand All @@ -48,7 +48,7 @@
'root'
end
describe user(usr), :node => node do
it { should exist }
it { is_expected.to exist }
end
end
end
Expand All @@ -61,16 +61,16 @@
'root'
end
describe user(usr) do
it { should exist }
it { is_expected.to exist }
end
end

context "serverspec: can match multiline file to multiline contents" do
contents = "four = five\n[one]\ntwo = three"
create_remote_file(default, "file_with_contents.txt", contents)
describe file("file_with_contents.txt") do
it { should be_file }
it { should contain(contents) }
it { is_expected.to be_file }
it { is_expected.to contain(contents) }
end
end
end