Skip to content

Commit

Permalink
(MAINT) Fix up places where we used .key? to check if flag was set
Browse files Browse the repository at this point in the history
Apparently this was never the documented Cri behavior and they recently
fixed this so that flags and other "no argument" options will have keys
set in the options hash with a value of "false" instead of simply being
absent from the options hash.
  • Loading branch information
scotje committed May 30, 2019
1 parent 0cb23cd commit dda53e2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/pdk/cli/test/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module PDK::CLI

# Ensure that the bundled gems are up to date and correct Ruby is activated before running or listing tests.
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
PDK::Util::PuppetVersion.fetch_puppet_dev if opts.key?(:'puppet-dev')
PDK::Util::PuppetVersion.fetch_puppet_dev if opts[:'puppet-dev']
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])

opts.merge!(puppet_env[:gemset])
Expand Down
4 changes: 2 additions & 2 deletions lib/pdk/cli/validate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ module PDK::CLI
end

options = targets.empty? ? {} : { targets: targets }
options[:auto_correct] = true if opts.key?(:'auto-correct')
options[:auto_correct] = true if opts[:'auto-correct']

# Ensure that the bundled gems are up to date and correct Ruby is activated before running any validations.
puppet_env = PDK::CLI::Util.puppet_from_opts_or_env(opts)
PDK::Util::PuppetVersion.fetch_puppet_dev if opts.key?(:'puppet-dev')
PDK::Util::PuppetVersion.fetch_puppet_dev if opts[:'puppet-dev']
PDK::Util::RubyVersion.use(puppet_env[:ruby_version])

options.merge!(puppet_env[:gemset])
Expand Down
2 changes: 1 addition & 1 deletion lib/pdk/generate/module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def self.module_interview(metadata, opts = {})
else
questions.reject! { |q| q[:name] == 'module_name' } if opts.key?(:module_name)
questions.reject! { |q| q[:name] == 'license' } if opts.key?(:license)
questions.reject! { |q| q[:forge_only] } unless opts.key?(:'full-interview')
questions.reject! { |q| q[:forge_only] } unless opts[:'full-interview']
end

interview.add_questions(questions)
Expand Down
10 changes: 5 additions & 5 deletions lib/pdk/tests/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module PDK
module Test
class Unit
def self.cmd(tests, opts = {})
rake_args = opts.key?(:parallel) ? 'parallel_spec_standalone' : 'spec_standalone'
rake_args = opts[:parallel] ? 'parallel_spec_standalone' : 'spec_standalone'
rake_args += "[#{tests}]" unless tests.nil?
rake_args
end
Expand Down Expand Up @@ -72,23 +72,23 @@ def self.invoke(report, options = {})

environment = { 'CI_SPEC_OPTIONS' => '--format j' }
environment['PUPPET_GEM_VERSION'] = options[:puppet] if options[:puppet]
spinner_msg = options.key?(:parallel) ? _('Running unit tests in parallel.') : _('Running unit tests.')
spinner_msg = options[:parallel] ? _('Running unit tests in parallel.') : _('Running unit tests.')
result = rake(cmd(tests, options), spinner_msg, environment)

json_result = if options.key?(:parallel)
json_result = if options[:parallel]
PDK::Util.find_all_json_in(result[:stdout])
else
PDK::Util.find_first_json_in(result[:stdout])
end

if parallel_with_no_tests?(options.key?(:parallel), json_result, result)
if parallel_with_no_tests?(options[:parallel], json_result, result)
json_result = [{ 'messages' => ['No examples found.'] }]
result[:exit_code] = 0
end

raise PDK::CLI::FatalError, _('Unit test output did not contain a valid JSON result: %{output}') % { output: result[:stdout] } if json_result.nil? || json_result.empty?

json_result = merge_json_results(json_result) if options.key?(:parallel)
json_result = merge_json_results(json_result) if options[:parallel]

parse_output(report, json_result, result[:duration])

Expand Down

0 comments on commit dda53e2

Please sign in to comment.