Sha256: 6d960d3ec630aa5694961fd8fd93589c0bb0492514fda179ee0145054e021f7a
Contents?: true
Size: 1.53 KB
Versions: 2
Compression:
Stored size: 1.53 KB
Contents
# Set up the environment for testing 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) @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel end def execute! $stdout = @stdout $stdin = @stdin kitchen_cli = Kitchen::CLI kitchen_cli.start(@argv) @kernel.exit(0) end end Before do @aruba_timeout_seconds = 15 @cleanup_dirs = [] Aruba::InProcess.main_class = ArubaHelper Aruba.process = Aruba::InProcess end Before('@spawn') do Aruba.process = Aruba::SpawnProcess end After do |s| # Tell Cucumber to quit after this scenario is done - if it failed. # This is useful to inspect the 'tmp/aruba' directory before any other # steps are executed and clear it out. Cucumber.wants_to_quit = true if s.failed? # 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) end @cleanup_dirs.each { |dir| FileUtils.rm_rf(dir) } end def backup_envvar(key) ENV["_CUKE_#{key}"] = ENV[key] end def restore_envvar(key) ENV[key] = ENV.delete("_CUKE_#{key}") end def unbundlerize keys = %w[BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT] keys.each { |key| backup_envvar(key) ; ENV.delete(key) } yield keys.each { |key| restore_envvar(key) } end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
test-kitchen-1.2.1 | features/support/env.rb |
test-kitchen-1.2.0 | features/support/env.rb |