Sha256: efa9c643695f57d83ac34b42f5d80e0f0497fe20c5758077ceb4a60e61de224d
Contents?: true
Size: 1.75 KB
Versions: 17
Compression:
Stored size: 1.75 KB
Contents
# -*- encoding: utf-8 -*- # 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 = argv @stdin = stdin @stdout = stdout @stderr = stderr @kernel = 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.config.command_launcher = :in_process aruba.config.main_class = ArubaHelper end Before("@spawn") do aruba.config.command_launcher = :spawn 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 = aruba.environment env.to_h.keys.select { |key| key =~ /^_CUKE_/ } .each do |backup_key| env[backup_key.sub(/^_CUKE_/, "")] = env[backup_key] env.delete(backup_key) end @cleanup_dirs.each { |dir| FileUtils.rm_rf(dir) } end def backup_envvar(key) aruba.environment["_CUKE_#{key}"] = aruba.environment[key] end def restore_envvar(key) aruba.environment[key] = aruba.environment["_CUKE_#{key}"] aruba.environment.delete("_CUKE_#{key}") end def unbundlerize keys = %w{BUNDLER_EDITOR BUNDLE_BIN_PATH BUNDLE_GEMFILE RUBYOPT} keys.each { |key| backup_envvar(key); aruba.environment.delete(key) } yield keys.each { |key| restore_envvar(key) } end
Version data entries
17 entries across 17 versions & 1 rubygems