Skip to content

Commit

Permalink
One of those tiny String tweak deals (style).
Browse files Browse the repository at this point in the history
  • Loading branch information
fnichol committed Jul 21, 2014
1 parent 4b9e96b commit aed0e3e
Show file tree
Hide file tree
Showing 76 changed files with 474 additions and 462 deletions.
20 changes: 10 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
require 'bundler/gem_tasks'
require "bundler/gem_tasks"

require 'rake/testtask'
require "rake/testtask"
Rake::TestTask.new(:unit) do |t|
t.libs.push "lib"
t.test_files = FileList['spec/**/*_spec.rb']
t.test_files = FileList["spec/**/*_spec.rb"]
t.verbose = true
end

require 'cucumber'
require 'cucumber/rake/task'
require "cucumber"
require "cucumber/rake/task"
Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = ['features', '-x', '--format progress']
t.cucumber_opts = ["features", "-x", "--format progress"]
end

desc "Run all test suites"
Expand All @@ -24,11 +24,11 @@ task :stats do
sh "countloc -r spec features"
end

if RUBY_ENGINE != 'jruby'
require 'cane/rake_task'
if RUBY_ENGINE != "jruby"
require "cane/rake_task"
desc "Run cane to check quality metrics"
Cane::RakeTask.new do |cane|
cane.canefile = './.cane'
cane.canefile = "./.cane"
end

desc "Run all quality tasks"
Expand All @@ -38,7 +38,7 @@ else
task :quality => [:stats]
end

require 'yard'
require "yard"
YARD::Rake::YardocTask.new

task :default => [:test, :quality]
6 changes: 3 additions & 3 deletions bin/kitchen
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Signal.trap("INT") { exit 1 }

$LOAD_PATH.unshift File.join(File.dirname(__FILE__), %w[.. lib])
require 'rubygems'
require 'kitchen/cli'
require 'kitchen/errors'
require "rubygems"
require "kitchen/cli"
require "kitchen/errors"

Kitchen.with_friendly_errors { Kitchen::CLI.start }
46 changes: 29 additions & 17 deletions features/kitchen_init_command.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ Feature: Add Test Kitchen support to an existing project
Scenario: Running init that creates a Gemfile
When I successfully run `kitchen init --create-gemfile`
Then the file "Gemfile" should contain "https://rubygems.org"
And the file "Gemfile" should contain "gem 'test-kitchen'"
And the file "Gemfile" should contain "gem 'kitchen-vagrant'"
And the file "Gemfile" should contain:
"""
gem "test-kitchen"
"""
And the file "Gemfile" should contain:
"""
gem "kitchen-vagrant"
"""
And the output should contain "You must run `bundle install'"

Scenario: Running init with an existing Gemfile appends to the Gemfile
Expand All @@ -52,8 +58,8 @@ Feature: Add Test Kitchen support to an existing project
"""
source "https://rubygems.org"
gem 'test-kitchen'
gem 'kitchen-vagrant'
gem "test-kitchen"
gem "kitchen-vagrant"
"""
And the output should contain "You must run `bundle install'"
Expand All @@ -64,16 +70,16 @@ Feature: Add Test Kitchen support to an existing project
"""
source "https://rubygems.org"
gem "test-kitchen"
gem 'test-kitchen'
"""
When I successfully run `kitchen init`
Then the file "Gemfile" should contain exactly:
"""
source "https://rubygems.org"
gem "test-kitchen"
gem 'kitchen-vagrant'
gem 'test-kitchen'
gem "kitchen-vagrant"
"""
And the output should contain "You must run `bundle install'"
Expand All @@ -84,26 +90,32 @@ Feature: Add Test Kitchen support to an existing project
"""
source "https://rubygems.org"
gem "test-kitchen"
gem "kitchen-ec2"
gem 'test-kitchen'
gem 'kitchen-ec2'
"""
When I successfully run `kitchen init --driver=kitchen-ec2`
Then the file "Gemfile" should contain exactly:
"""
source "https://rubygems.org"
gem "test-kitchen"
gem "kitchen-ec2"
gem 'test-kitchen'
gem 'kitchen-ec2'
"""
And the output should not contain "You must run `bundle install'"

Scenario: Running init with multiple drivers appends to the Gemfile
Given an empty file named "Gemfile"
When I successfully run `kitchen init --driver=kitchen-bluebox kitchen-wakka`
Then the file "Gemfile" should contain "gem 'kitchen-bluebox'"
And the file "Gemfile" should contain "gem 'kitchen-wakka'"
Then the file "Gemfile" should contain:
"""
gem "kitchen-bluebox"
"""
And the file "Gemfile" should contain:
"""
gem "kitchen-wakka"
"""
And the output should contain "You must run `bundle install'"

Scenario: Running init with multiple driver sets the plugin_driver to the
Expand Down Expand Up @@ -152,10 +164,10 @@ Feature: Add Test Kitchen support to an existing project
Then the file "Rakefile" should contain:
"""
begin
require 'kitchen/rake_tasks'
require "kitchen/rake_tasks"
Kitchen::RakeTasks.new
rescue LoadError
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"]
end
"""

Expand All @@ -171,10 +183,10 @@ Feature: Add Test Kitchen support to an existing project
Then the file "Thorfile" should contain:
"""
begin
require 'kitchen/thor_tasks'
require "kitchen/thor_tasks"
Kitchen::ThorTasks.new
rescue LoadError
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI']
puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV["CI"]
end
"""

Expand Down
12 changes: 6 additions & 6 deletions features/step_definitions/gem_steps.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'tmpdir'
require 'pathname'
require "tmpdir"
require "pathname"

Given(/^a sandboxed GEM_HOME directory named "(.*?)"$/) do |name|
backup_envvar('GEM_HOME')
backup_envvar('GEM_PATH')
backup_envvar("GEM_HOME")
backup_envvar("GEM_PATH")

@aruba_timeout_seconds = 30

gem_home = Pathname.new(Dir.mktmpdir(name))
ENV['GEM_HOME'] = gem_home.to_s
ENV['GEM_PATH'] = [gem_home.to_s, ENV['GEM_PATH']].join(':')
ENV["GEM_HOME"] = gem_home.to_s
ENV["GEM_PATH"] = [gem_home.to_s, ENV["GEM_PATH"]].join(":")
@cleanup_dirs << gem_home
end

Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/git_steps.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Given(/I have a git repository/) do
create_dir('.git')
create_dir(".git")
end
14 changes: 7 additions & 7 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Set up the environment for testing
require 'aruba/cucumber'
require 'aruba/in_process'
require 'aruba/spawn_process'
require 'kitchen'
require 'kitchen/cli'
require "aruba/cucumber"
require "aruba/in_process"
require "aruba/spawn_process"
require "kitchen"
require "kitchen/cli"

class ArubaHelper
def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
Expand All @@ -28,7 +28,7 @@ def execute!
Aruba.process = Aruba::InProcess
end

Before('@spawn') do
Before("@spawn") do
Aruba.process = Aruba::SpawnProcess
end

Expand All @@ -41,7 +41,7 @@ def execute!
# Restore environment variables to their original settings, if they have
# been saved off
ENV.keys.select { |key| key =~ /^_CUKE_/ }.each do |backup_key|
ENV[backup_key.sub(/^_CUKE_/, '')] = ENV.delete(backup_key)
ENV[backup_key.sub(/^_CUKE_/, "")] = ENV.delete(backup_key)
end

@cleanup_dirs.each { |dir| FileUtils.rm_rf(dir) }
Expand Down
62 changes: 31 additions & 31 deletions lib/kitchen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'pathname'
require 'thread'

require 'kitchen/errors'
require 'kitchen/logger'
require 'kitchen/logging'
require 'kitchen/shell_out'
require 'kitchen/configurable'
require 'kitchen/util'

require 'kitchen/provisioner'
require 'kitchen/provisioner/base'
require 'kitchen/busser'
require 'kitchen/color'
require 'kitchen/collection'
require 'kitchen/config'
require 'kitchen/data_munger'
require 'kitchen/driver'
require 'kitchen/driver/base'
require 'kitchen/driver/ssh_base'
require 'kitchen/driver/proxy'
require 'kitchen/instance'
require 'kitchen/loader/yaml'
require 'kitchen/metadata_chopper'
require 'kitchen/platform'
require 'kitchen/state_file'
require 'kitchen/ssh'
require 'kitchen/suite'
require 'kitchen/version'
require "pathname"
require "thread"

require "kitchen/errors"
require "kitchen/logger"
require "kitchen/logging"
require "kitchen/shell_out"
require "kitchen/configurable"
require "kitchen/util"

require "kitchen/provisioner"
require "kitchen/provisioner/base"
require "kitchen/busser"
require "kitchen/color"
require "kitchen/collection"
require "kitchen/config"
require "kitchen/data_munger"
require "kitchen/driver"
require "kitchen/driver/base"
require "kitchen/driver/ssh_base"
require "kitchen/driver/proxy"
require "kitchen/instance"
require "kitchen/loader/yaml"
require "kitchen/metadata_chopper"
require "kitchen/platform"
require "kitchen/state_file"
require "kitchen/ssh"
require "kitchen/suite"
require "kitchen/version"

# Test Kitchen base module.
#
Expand All @@ -63,7 +63,7 @@ class << self
#
# @return [Pathname] root path of gem
def source_root
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
end

# Returns a default logger which emits on standard output.
Expand All @@ -90,7 +90,7 @@ def default_file_logger
# @return [Integer,nil] a log level or nil if not set
# @api private
def env_log
level = ENV['KITCHEN_LOG'] && ENV['KITCHEN_LOG'].downcase.to_sym
level = ENV["KITCHEN_LOG"] && ENV["KITCHEN_LOG"].downcase.to_sym
level = Util.to_logger_level(level) unless level.nil?
level
end
Expand Down
18 changes: 9 additions & 9 deletions lib/kitchen/busser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

require 'base64'
require 'digest'
require "base64"
require "digest"

module Kitchen

Expand Down Expand Up @@ -101,15 +101,15 @@ def setup_cmd
gem = sudo("#{config[:ruby_bindir]}/gem")
busser = sudo(config[:busser_bin])

cmd = <<-CMD.gsub(/^ {8}/, '')
cmd = <<-CMD.gsub(/^ {8}/, "")
#{busser_setup_env}
gem_bindir=`#{ruby} -rrubygems -e "puts Gem.bindir"`
if ! #{gem} list busser -i >/dev/null; then
#{gem} install #{gem_install_args}
fi
#{sudo("${gem_bindir}")}/busser setup
#{busser} plugin install #{plugins.join(' ')}
#{busser} plugin install #{plugins.join(" ")}
CMD
Util.wrap_command(cmd)
end
Expand All @@ -125,7 +125,7 @@ def setup_cmd
def sync_cmd
return if local_suite_files.empty?

cmd = <<-CMD.gsub(/^ {8}/, '')
cmd = <<-CMD.gsub(/^ {8}/, "")
#{busser_setup_env}
#{sudo(config[:busser_bin])} suite cleanup
Expand All @@ -151,7 +151,7 @@ def sync_cmd
def run_cmd
return if local_suite_files.empty?

cmd = <<-CMD.gsub(/^ {8}/, '')
cmd = <<-CMD.gsub(/^ {8}/, "")
#{busser_setup_env}
#{sudo(config[:busser_bin])} test
Expand Down Expand Up @@ -181,7 +181,7 @@ def validate_options(suite_name)
raise ClientError, "Busser#new requires a suite_name"
end

if suite_name == 'helper'
if suite_name == "helper"
raise UserError,
"Suite name invalid: 'helper' is a reserved directory name."
end
Expand Down Expand Up @@ -245,7 +245,7 @@ def helper_files
def remote_file(file, dir)
local_prefix = File.join(config[:test_base_path], dir)
"`#{sudo(config[:busser_bin])} suite path`/".
concat(file.sub(%r{^#{local_prefix}/}, ''))
concat(file.sub(%r{^#{local_prefix}/}, ""))
end

# Returns a command string that will, once evaluated, result in the copying
Expand All @@ -257,7 +257,7 @@ def remote_file(file, dir)
# @api private
def stream_file(local_path, remote_path)
local_file = IO.read(local_path)
encoded_file = Base64.encode64(local_file).gsub("\n", '')
encoded_file = Base64.encode64(local_file).gsub("\n", "")
md5 = Digest::MD5.hexdigest(local_file)
perms = format("%o", File.stat(local_path).mode)[2, 4]
stream_cmd = [
Expand Down
Loading

0 comments on commit aed0e3e

Please sign in to comment.