lib/chef-dk/component_test.rb in chef-dk-1.2.22 vs lib/chef-dk/component_test.rb in chef-dk-1.3.40

- old
+ new

@@ -13,12 +13,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # -require 'chef-dk/exceptions' -require 'chef-dk/helpers' +require "chef-dk/exceptions" +require "chef-dk/helpers" # https://github.com/bundler/bundler/issues/4368 # As of rubygems 2.6.2, Rubygems will call Bundler::SpecSet#size, which does # not exist as of Bundler 1.11.2. # @@ -105,11 +105,11 @@ def embedded_bin(binary) File.join(omnibus_embedded_bin_dir, binary) end - def sh(command, options={}) + def sh(command, options = {}) combined_opts = default_command_options.merge(options) # Env is a hash, so it needs to be merged separately if options.key?(:env) combined_opts[:env] = default_command_options[:env].merge(options[:env]) @@ -130,19 +130,19 @@ # Run a command, if the command returns zero, raise an error, # otherwise, if it returns non-zero or doesn't exist, # return a passing command so that the test parser doesn't # crash. - def fail_if_exit_zero(cmd_string, failure_string='') + def fail_if_exit_zero(cmd_string, failure_string = "") result = sh(cmd_string) if result.status.exitstatus == 0 - raise failure_string + raise failure_string else - sh('true') + sh("true") end rescue Errno::ENOENT - sh('true') + sh("true") end def nix_platform_native_bin_dir if /sunos|solaris/ =~ RUBY_PLATFORM "/opt/local/bin" @@ -151,11 +151,11 @@ else "/usr/bin" end end - def run_in_tmpdir(command, options={}) + def run_in_tmpdir(command, options = {}) tmpdir do |dir| options[:cwd] = dir sh(command, options) end end @@ -178,13 +178,13 @@ { :cwd => component_path, :env => { # Add the embedded/bin to the PATH so that bundle executable can # be found while running the tests. - path_variable_key => omnibus_path + path_variable_key => omnibus_path, }, - :timeout => 3600 + :timeout => 3600, } end def component_path if base_dir @@ -201,23 +201,23 @@ # There is no way to say "give me the latest prerelease OR normal version of this gem. # So we first ask if there is a normal version, and if there is not, we ask if there # is a prerelease version. ">= 0.a" is how we ask for a prerelease version, because a # prerelease version is defined as "any version with a letter in it." gem = Gem::Specification.find_by_name(@gem_name_for_base_dir) - gem ||= Gem::Specification.find_by_name(@gem_name_for_base_dir, '>= 0.a') + gem ||= Gem::Specification.find_by_name(@gem_name_for_base_dir, ">= 0.a") gem.gem_dir end def gem_base_dir=(gem_name) @gem_name_for_base_dir = gem_name end def omnibus_root - @omnibus_root or raise "`omnibus_root` must be set before running tests" + @omnibus_root || raise("`omnibus_root` must be set before running tests") end def omnibus_path - [omnibus_bin_dir, omnibus_embedded_bin_dir, ENV['PATH']].join(File::PATH_SEPARATOR) + [omnibus_bin_dir, omnibus_embedded_bin_dir, ENV["PATH"]].join(File::PATH_SEPARATOR) end def path_variable_key ENV.keys.grep(/\Apath\Z/i).first end