aruba 0.8.1 → 0.9.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +3 -1
- data/Gemfile +13 -10
- data/History.md +25 -7
- data/README.md +6 -1
- data/Rakefile +16 -3
- data/aruba.gemspec +10 -2
- data/bin/aruba +7 -0
- data/cucumber.yml +11 -2
- data/features/api/command/extract_text.feature +97 -0
- data/features/api/command/unescape_text.feature +119 -0
- data/features/api/core/expand_path.feature +16 -0
- data/features/api/{cd.feature → filesystem/cd.feature} +2 -1
- data/features/api/filesystem/create_directory.feature +57 -0
- data/features/api/filesystem/disk_usage.feature +151 -0
- data/features/api/filesystem/does_exist.feature +62 -0
- data/features/api/filesystem/is_absolute.feature +48 -0
- data/features/api/filesystem/is_directory.feature +53 -0
- data/features/api/filesystem/is_file.feature +54 -0
- data/features/api/filesystem/is_relative.feature +48 -0
- data/features/cli/console.feature +52 -0
- data/features/configuration/console_history_file.feature +38 -0
- data/features/configuration/exit_timeout.feature +2 -1
- data/features/configuration/fixtures_path_prefix.feature +0 -1
- data/features/configuration/home_directory.feature +0 -1
- data/features/configuration/io_timeout.feature +0 -1
- data/features/configuration/keep_ansi.feature +1 -2
- data/features/configuration/log_level.feature +38 -0
- data/features/configuration/physical_block_size.feature +53 -0
- data/features/configuration/remove_ansi_escape_sequences.feature +38 -0
- data/features/configuration/root_directory.feature +0 -1
- data/features/configuration/working_directory.feature +2 -1
- data/features/fixtures/cli-app/README.md +5 -0
- data/features/fixtures/cli-app/lib/cli/app.rb +1 -1
- data/features/fixtures/cli-app/spec/spec_helper.rb +1 -2
- data/features/fixtures/cli-app/spec/support/aruba.rb +1 -0
- data/features/fixtures/empty-app/lib/cli/app.rb +1 -1
- data/features/fixtures/empty-app/spec/spec_helper.rb +1 -1
- data/features/step_definitions/aruba_dev_steps.rb +12 -1
- data/features/support/env.rb +1 -1
- data/lib/aruba/announcer.rb +1 -14
- data/lib/aruba/api.rb +6 -6
- data/lib/aruba/api/command.rb +74 -12
- data/lib/aruba/api/core.rb +18 -11
- data/lib/aruba/api/deprecated.rb +60 -72
- data/lib/aruba/api/filesystem.rb +41 -16
- data/lib/aruba/aruba_logger.rb +77 -0
- data/lib/aruba/aruba_path.rb +33 -0
- data/lib/aruba/basic_configuration.rb +2 -2
- data/lib/aruba/cli.rb +11 -0
- data/lib/aruba/config.rb +13 -3
- data/lib/aruba/config/jruby.rb +5 -2
- data/lib/aruba/console.rb +66 -0
- data/lib/aruba/console/help.rb +33 -0
- data/lib/aruba/contracts/is_power_of_two.rb +15 -0
- data/lib/aruba/cucumber.rb +27 -10
- data/lib/aruba/cucumber/hooks.rb +15 -8
- data/lib/aruba/disk_usage_calculator.rb +7 -0
- data/lib/aruba/file_size.rb +52 -0
- data/lib/aruba/in_process.rb +1 -1
- data/lib/aruba/jruby.rb +1 -1
- data/lib/aruba/matchers/command.rb +1 -1
- data/lib/aruba/matchers/directory.rb +1 -1
- data/lib/aruba/matchers/environment.rb +1 -1
- data/lib/aruba/matchers/file.rb +1 -1
- data/lib/aruba/matchers/path.rb +1 -1
- data/lib/aruba/matchers/path/match_path_pattern.rb +1 -1
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
- data/lib/aruba/platform.rb +14 -242
- data/lib/aruba/{creators → platforms}/aruba_file_creator.rb +3 -3
- data/lib/aruba/{creators → platforms}/aruba_fixed_size_file_creator.rb +2 -2
- data/lib/aruba/platforms/simple_table.rb +36 -0
- data/lib/aruba/platforms/unix_command_string.rb +24 -0
- data/lib/aruba/platforms/unix_environment_variables.rb +130 -0
- data/lib/aruba/platforms/unix_platform.rb +226 -0
- data/lib/aruba/platforms/unix_which.rb +83 -0
- data/lib/aruba/platforms/windows_command_string.rb +23 -0
- data/lib/aruba/platforms/windows_environment_variables.rb +83 -0
- data/lib/aruba/platforms/windows_platform.rb +39 -0
- data/lib/aruba/platforms/windows_which.rb +104 -0
- data/lib/aruba/process_monitor.rb +3 -3
- data/lib/aruba/processes/basic_process.rb +23 -3
- data/lib/aruba/processes/debug_process.rb +2 -2
- data/lib/aruba/processes/in_process.rb +1 -1
- data/lib/aruba/processes/spawn_process.rb +10 -4
- data/lib/aruba/reporting.rb +1 -1
- data/lib/aruba/rspec.rb +8 -6
- data/lib/aruba/runtime.rb +8 -5
- data/lib/aruba/version.rb +1 -1
- data/spec/aruba/api_spec.rb +25 -23
- data/spec/aruba/aruba_path_spec.rb +37 -0
- data/spec/aruba/jruby_spec.rb +1 -1
- data/spec/aruba/matchers/file_spec.rb +2 -2
- data/spec/aruba/matchers/path_spec.rb +3 -3
- data/spec/aruba/platform/simple_table_spec.rb +23 -0
- data/spec/aruba/platform/windows_environment_variables_spec.rb +500 -0
- data/spec/aruba/spawn_process_spec.rb +3 -1
- metadata +90 -12
- data/lib/aruba/contracts/is_a.rb +0 -21
- data/lib/aruba/environment.rb +0 -121
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'delegate'
|
2
|
+
|
3
|
+
module Aruba
|
4
|
+
module Platforms
|
5
|
+
# This is a command which should be run
|
6
|
+
class WindowsCommandString < SimpleDelegator
|
7
|
+
def initialize(cmd)
|
8
|
+
__setobj__ format('%s /c "%s"', Aruba.platform.which('cmd.exe'), cmd)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_a
|
12
|
+
Shellwords.split __getobj__
|
13
|
+
end
|
14
|
+
|
15
|
+
if RUBY_VERSION < '1.9'
|
16
|
+
def to_s
|
17
|
+
__getobj__.to_s
|
18
|
+
end
|
19
|
+
alias_method :inspect, :to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'aruba/platforms/unix_environment_variables'
|
2
|
+
|
3
|
+
module Aruba
|
4
|
+
module Platforms
|
5
|
+
# Windows is case-insensitive when it accesses its environment variables.
|
6
|
+
# That means that at the Windows command line:
|
7
|
+
#
|
8
|
+
# C:>set Path
|
9
|
+
# C:>Path=.;.\bin;c:\rubys\ruby-2.1.6-p336\bin;
|
10
|
+
# C:>set PATH
|
11
|
+
# C:>Path=.;.\bin;c:\rubys\ruby-2.1.6-p336\bin;
|
12
|
+
#
|
13
|
+
# If you access environment variables through ENV, you can access values no
|
14
|
+
# matter the case of the key:
|
15
|
+
#
|
16
|
+
# irb: > ENV["Path"]
|
17
|
+
# => ".;.\bin;c:\rubys\ruby-2.1.6-p336\bin;"
|
18
|
+
# irb: > ENV["Path"]
|
19
|
+
# => ".;.\bin;c:\rubys\ruby-2.1.6-p336\bin;"
|
20
|
+
#
|
21
|
+
# But if you copy the ENV to a hash, Ruby treats the keys as case sensitive:
|
22
|
+
#
|
23
|
+
# irb: > env_copy = ENV.to_hash
|
24
|
+
# => {"ALLUSERSPROFILE"=>"C:\\ProgramData", "ANSICON"=>"119x1000 (119x58)", "ANSICON_DEF"=>"7", APPDATA"=>"C:\\Users\\blorf\\AppData\\Roaming", ....}
|
25
|
+
# irb: > env["Path"]
|
26
|
+
# => ".;.\bin;c:\rubys\ruby-2.1.6-p336\bin;"
|
27
|
+
# irb: > env["PATH"]
|
28
|
+
# => nil
|
29
|
+
#
|
30
|
+
# Thus we turn all of the environment variable keys to upper case so that
|
31
|
+
# aruba is ensured that accessing environment variables with upper case keys
|
32
|
+
# will always work.
|
33
|
+
class WindowsEnvironmentVariables < UnixEnvironmentVariables
|
34
|
+
def initialize(env = ENV.to_hash)
|
35
|
+
@env = Marshal.load(Marshal.dump(env))
|
36
|
+
|
37
|
+
if RUBY_VERSION <= '1.9.3'
|
38
|
+
# rubocop:disable Style/EachWithObject
|
39
|
+
@env = @env.inject({}) { |a, (k,v)| a[k.to_s.upcase] = v; a }
|
40
|
+
# rubocop:enable Style/EachWithObject
|
41
|
+
else
|
42
|
+
@env = @env.each_with_object({}) { |(k,v), a| a[k.to_s.upcase] = v }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def update(other_env, &block)
|
47
|
+
if RUBY_VERSION <= '1.9.3'
|
48
|
+
# rubocop:disable Style/EachWithObject
|
49
|
+
other_env = other_env.inject({}) { |a, (k,v)| a[k.to_s.upcase] = v; a }
|
50
|
+
# rubocop:enable Style/EachWithObject
|
51
|
+
else
|
52
|
+
other_env = other_env.each_with_object({}) { |(k,v), a| a[k.to_s.upcase] = v }
|
53
|
+
end
|
54
|
+
|
55
|
+
super(other_env, &block)
|
56
|
+
end
|
57
|
+
|
58
|
+
def fetch(name, default = UnixEnvironmentVariables::UNDEFINED)
|
59
|
+
super(name.upcase, default)
|
60
|
+
end
|
61
|
+
|
62
|
+
def key?(name)
|
63
|
+
super(name.upcase)
|
64
|
+
end
|
65
|
+
|
66
|
+
def [](name)
|
67
|
+
super(name.upcase)
|
68
|
+
end
|
69
|
+
|
70
|
+
def []=(name, value)
|
71
|
+
super(name.upcase, value)
|
72
|
+
end
|
73
|
+
|
74
|
+
def append(name, value)
|
75
|
+
super(name.upcase, value)
|
76
|
+
end
|
77
|
+
|
78
|
+
def prepend(name, value)
|
79
|
+
super(name.upcase, value)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'ffi'
|
2
|
+
|
3
|
+
require 'aruba/platforms/unix_platform'
|
4
|
+
require 'aruba/platforms/windows_command_string'
|
5
|
+
require 'aruba/platforms/windows_environment_variables'
|
6
|
+
require 'aruba/platforms/windows_which'
|
7
|
+
|
8
|
+
module Aruba
|
9
|
+
# This abstracts OS-specific things
|
10
|
+
module Platforms
|
11
|
+
# WARNING:
|
12
|
+
# All methods found here are not considered part of the public API of aruba.
|
13
|
+
#
|
14
|
+
# Those methods can be changed at any time in the feature or removed without
|
15
|
+
# any further notice.
|
16
|
+
#
|
17
|
+
# This includes all methods for the Windows platform
|
18
|
+
class WindowsPlatform < UnixPlatform
|
19
|
+
def self.match?
|
20
|
+
FFI::Platform.windows?
|
21
|
+
end
|
22
|
+
|
23
|
+
# @see UnixPlatform#command_string
|
24
|
+
def command_string
|
25
|
+
WindowsCommandString
|
26
|
+
end
|
27
|
+
|
28
|
+
# @see UnixPlatform#environment_variables
|
29
|
+
def environment_variables
|
30
|
+
WindowsEnvironmentVariables.new
|
31
|
+
end
|
32
|
+
|
33
|
+
# @see UnixPlatform#which
|
34
|
+
def which(program, path = ENV['PATH'])
|
35
|
+
WindowsWhich.new.call(program, path)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'aruba/platform'
|
2
|
+
|
3
|
+
module Aruba
|
4
|
+
module Platforms
|
5
|
+
# Implement `which(command)` for windows
|
6
|
+
class WindowsWhich
|
7
|
+
# Bail out because this should never be reached
|
8
|
+
class DefaultWhich
|
9
|
+
def self.match?(*)
|
10
|
+
true
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(program, path)
|
14
|
+
fail %(Invalid input program "#{program}" and/or path "#{path}".)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Find path for absolute or relative command
|
19
|
+
class AbsoluteOrRelativePathWhich
|
20
|
+
def self.match?(program)
|
21
|
+
Aruba.platform.absolute_path?(program) || Aruba.platform.relative_command?(program)
|
22
|
+
end
|
23
|
+
|
24
|
+
def call(program, path)
|
25
|
+
# Expand `#path_exts`
|
26
|
+
found = Dir[program].first
|
27
|
+
|
28
|
+
return File.expand_path(found) if found && Aruba.platform.executable_file?(found)
|
29
|
+
nil
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Find path for command
|
34
|
+
class ProgramWhich
|
35
|
+
def self.match?(program)
|
36
|
+
Aruba.platform.command?(program)
|
37
|
+
end
|
38
|
+
|
39
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
40
|
+
# rubocop:disable Metrics/MethodLength
|
41
|
+
def call(program, path)
|
42
|
+
# Iterate over each path glob the dir + program.
|
43
|
+
path.split(File::PATH_SEPARATOR).each do |dir|
|
44
|
+
dir = Aruba.platform.expand_path(dir, Dir.getwd)
|
45
|
+
|
46
|
+
next unless Aruba.platform.exist?(dir) # In case of bogus second argument
|
47
|
+
|
48
|
+
file = File.join(dir, program)
|
49
|
+
# Dir[] doesn't handle backslashes properly, so convert them. Also, if
|
50
|
+
# the program name doesn't have an extension, try them all.
|
51
|
+
file = file.tr("\\", "/")
|
52
|
+
|
53
|
+
found = Dir[file].first
|
54
|
+
|
55
|
+
# Convert all forward slashes to backslashes if supported
|
56
|
+
if found && Aruba.platform.executable_file?(found)
|
57
|
+
found.tr!(File::SEPARATOR, File::ALT_SEPARATOR)
|
58
|
+
return found
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
65
|
+
# rubocop:enable Metrics/MethodLength
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
attr_reader :whiches
|
71
|
+
|
72
|
+
public
|
73
|
+
|
74
|
+
def initialize
|
75
|
+
@whiches = []
|
76
|
+
@whiches << AbsoluteOrRelativePathWhich
|
77
|
+
@whiches << ProgramWhich
|
78
|
+
@whiches << DefaultWhich
|
79
|
+
end
|
80
|
+
|
81
|
+
# Find fully quallified path for program
|
82
|
+
#
|
83
|
+
# @param [String] program
|
84
|
+
# Name of program
|
85
|
+
#
|
86
|
+
# @param [String] path
|
87
|
+
# ENV['PATH']
|
88
|
+
def call(program, path = ENV['PATH'])
|
89
|
+
raise ArgumentError, "ENV['PATH'] cannot be empty" if path.nil? || path.empty?
|
90
|
+
|
91
|
+
program = program.to_s
|
92
|
+
program += windows_executable_extentions if File.extname(program).empty?
|
93
|
+
|
94
|
+
whiches.find { |w| w.match? program }.new.call(program, path)
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def windows_executable_extentions
|
100
|
+
ENV['PATHEXT'] ? format('.{%s}', ENV['PATHEXT'].tr(';', ',').tr('.','')).downcase : '.{exe,com,bat}'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -60,7 +60,7 @@ module Aruba
|
|
60
60
|
# @param [String] cmd
|
61
61
|
# The command
|
62
62
|
def output_from(cmd)
|
63
|
-
cmd =
|
63
|
+
cmd = Aruba.platform.detect_ruby(cmd)
|
64
64
|
get_process(cmd).output
|
65
65
|
end
|
66
66
|
|
@@ -69,7 +69,7 @@ module Aruba
|
|
69
69
|
# @param [String] cmd
|
70
70
|
# The command
|
71
71
|
def stdout_from(cmd)
|
72
|
-
cmd =
|
72
|
+
cmd = Aruba.platform.detect_ruby(cmd)
|
73
73
|
get_process(cmd).stdout
|
74
74
|
end
|
75
75
|
|
@@ -78,7 +78,7 @@ module Aruba
|
|
78
78
|
# @param [String] cmd
|
79
79
|
# The command
|
80
80
|
def stderr_from(cmd)
|
81
|
-
cmd =
|
81
|
+
cmd = Aruba.platform.detect_ruby(cmd)
|
82
82
|
get_process(cmd).stderr
|
83
83
|
end
|
84
84
|
|
@@ -6,7 +6,7 @@ module Aruba
|
|
6
6
|
class BasicProcess
|
7
7
|
attr_reader :exit_status, :environment
|
8
8
|
|
9
|
-
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash, main_class = nil)
|
9
|
+
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash.dup, main_class = nil)
|
10
10
|
@cmd = cmd
|
11
11
|
@working_directory = working_directory
|
12
12
|
@environment = environment
|
@@ -24,6 +24,26 @@ module Aruba
|
|
24
24
|
stdout + stderr
|
25
25
|
end
|
26
26
|
|
27
|
+
def write(*)
|
28
|
+
NotImplementedError
|
29
|
+
end
|
30
|
+
|
31
|
+
def stdin(*)
|
32
|
+
NotImplementedError
|
33
|
+
end
|
34
|
+
|
35
|
+
def stdout(*)
|
36
|
+
NotImplementedError
|
37
|
+
end
|
38
|
+
|
39
|
+
def stderr(*)
|
40
|
+
NotImplementedError
|
41
|
+
end
|
42
|
+
|
43
|
+
def close_io(*)
|
44
|
+
NotImplementedError
|
45
|
+
end
|
46
|
+
|
27
47
|
# Was process already stopped
|
28
48
|
def stopped?
|
29
49
|
@stopped == true
|
@@ -42,8 +62,8 @@ module Aruba
|
|
42
62
|
|
43
63
|
private
|
44
64
|
|
45
|
-
def which(program
|
46
|
-
Aruba
|
65
|
+
def which(program)
|
66
|
+
Aruba.platform.which(program, environment['PATH'])
|
47
67
|
end
|
48
68
|
|
49
69
|
def command
|
@@ -13,12 +13,12 @@ module Aruba
|
|
13
13
|
# rubocop:disable Metrics/CyclomaticComplexity
|
14
14
|
def run!
|
15
15
|
# rubocop:disable Metrics/LineLength
|
16
|
-
fail LaunchError, %(Command "#{command}" not found in PATH-variable "#{environment['PATH']}".) unless which(command
|
16
|
+
fail LaunchError, %(Command "#{command}" not found in PATH-variable "#{environment['PATH']}".) unless which(command)
|
17
17
|
# rubocop:enable Metrics/LineLength
|
18
18
|
|
19
19
|
if RUBY_VERSION < '1.9'
|
20
20
|
begin
|
21
|
-
old_env = ENV.to_hash
|
21
|
+
old_env = ENV.to_hash.dup
|
22
22
|
ENV.update environment
|
23
23
|
|
24
24
|
Dir.chdir @working_directory do
|
@@ -31,7 +31,7 @@ module Aruba
|
|
31
31
|
|
32
32
|
attr_reader :main_class
|
33
33
|
|
34
|
-
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash, main_class = nil)
|
34
|
+
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash.dup, main_class = nil)
|
35
35
|
@cmd = cmd
|
36
36
|
@argv = arguments
|
37
37
|
@stdin = StringIO.new
|
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'childprocess'
|
2
2
|
require 'tempfile'
|
3
3
|
require 'shellwords'
|
4
|
+
|
4
5
|
require 'aruba/errors'
|
5
6
|
require 'aruba/processes/basic_process'
|
7
|
+
require 'aruba/platform'
|
6
8
|
|
7
9
|
module Aruba
|
8
10
|
module Processes
|
@@ -25,7 +27,7 @@ module Aruba
|
|
25
27
|
#
|
26
28
|
# @params [String] working_directory
|
27
29
|
# The directory where the command will be executed
|
28
|
-
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash, main_class = nil)
|
30
|
+
def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash.dup, main_class = nil)
|
29
31
|
super
|
30
32
|
|
31
33
|
@exit_timeout = exit_timeout
|
@@ -43,11 +45,15 @@ module Aruba
|
|
43
45
|
# rubocop:disable Metrics/MethodLength
|
44
46
|
# rubocop:disable Metrics/CyclomaticComplexity
|
45
47
|
def run!
|
48
|
+
# gather fully qualified path
|
49
|
+
cmd = which(command)
|
46
50
|
# rubocop:disable Metrics/LineLength
|
47
|
-
fail LaunchError, %(Command "#{command}" not found in PATH-variable "#{environment['PATH']}".)
|
51
|
+
fail LaunchError, %(Command "#{command}" not found in PATH-variable "#{environment['PATH']}".) if cmd.nil?
|
48
52
|
# rubocop:enable Metrics/LineLength
|
49
53
|
|
50
|
-
|
54
|
+
cmd = Aruba.platform.command_string.new(cmd)
|
55
|
+
|
56
|
+
@process = ChildProcess.build(*[cmd.to_a, arguments].flatten)
|
51
57
|
@out = Tempfile.new("aruba-out")
|
52
58
|
@err = Tempfile.new("aruba-err")
|
53
59
|
@exit_status = nil
|
@@ -65,7 +71,7 @@ module Aruba
|
|
65
71
|
begin
|
66
72
|
@process.start
|
67
73
|
rescue ChildProcess::LaunchError => e
|
68
|
-
raise LaunchError, e.message
|
74
|
+
raise LaunchError, "It tried to start #{cmd}. " + e.message
|
69
75
|
end
|
70
76
|
|
71
77
|
after_run
|
data/lib/aruba/reporting.rb
CHANGED
@@ -50,7 +50,7 @@ if(ENV['ARUBA_REPORT_DIR'])
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def output
|
53
|
-
|
53
|
+
aruba.config.keep_ansi = true # We want the output coloured!
|
54
54
|
escaped_stdout = CGI.escapeHTML(all_stdout)
|
55
55
|
html = Bcat::ANSI.new(escaped_stdout).to_html
|
56
56
|
Bcat::ANSI::STYLES.each do |name, style|
|
data/lib/aruba/rspec.rb
CHANGED
@@ -14,17 +14,19 @@ RSpec.configure do |config|
|
|
14
14
|
config.include Aruba::Api, :type => :aruba
|
15
15
|
|
16
16
|
# Setup environment for aruba
|
17
|
-
config.
|
18
|
-
|
17
|
+
config.around :each do |example|
|
18
|
+
if self.class.include? Aruba::Api
|
19
|
+
restore_env
|
20
|
+
setup_aruba
|
21
|
+
end
|
19
22
|
|
20
|
-
|
21
|
-
setup_aruba
|
23
|
+
example.run
|
22
24
|
end
|
23
25
|
|
24
26
|
if Aruba::VERSION >= '1.0.0'
|
25
27
|
config.around :each do |example|
|
26
28
|
begin
|
27
|
-
old_env = ENV.to_hash
|
29
|
+
old_env = ENV.to_hash.dup
|
28
30
|
example.run
|
29
31
|
ensure
|
30
32
|
ENV.clear
|
@@ -45,7 +47,7 @@ RSpec.configure do |config|
|
|
45
47
|
next unless self.class.include?(Aruba::Api)
|
46
48
|
|
47
49
|
if example.metadata[:announce_environment]
|
48
|
-
Aruba
|
50
|
+
Aruba.platform.deprecated 'announce_environment is deprecated. Use announce_modified_environment instead'
|
49
51
|
|
50
52
|
announcer.activate(:modified_environment)
|
51
53
|
end
|
data/lib/aruba/runtime.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
require 'aruba/config'
|
2
|
-
require 'aruba/
|
2
|
+
require 'aruba/aruba_logger'
|
3
3
|
|
4
4
|
module Aruba
|
5
5
|
class Runtime
|
6
|
-
attr_reader :config, :current_directory, :environment, :root_directory
|
6
|
+
attr_reader :config, :current_directory, :environment, :root_directory, :logger
|
7
7
|
|
8
8
|
def initialize
|
9
9
|
@config = Aruba.config.make_copy
|
10
10
|
@current_directory = ArubaPath.new(@config.working_directory)
|
11
11
|
@root_directory = ArubaPath.new(@config.root_directory)
|
12
|
-
@environment =
|
12
|
+
@environment = Aruba.platform.environment_variables
|
13
|
+
|
14
|
+
@logger = ArubaLogger.new
|
15
|
+
@logger.mode = @config.log_level
|
13
16
|
end
|
14
17
|
|
15
18
|
# The path to the directory which contains fixtures
|
@@ -20,12 +23,12 @@ module Aruba
|
|
20
23
|
def fixtures_directory
|
21
24
|
unless @fixtures_directory
|
22
25
|
candidates = config.fixtures_directories.map { |dir| File.join(root_directory, dir) }
|
23
|
-
@fixtures_directory = candidates.find { |d| Aruba
|
26
|
+
@fixtures_directory = candidates.find { |d| Aruba.platform.directory? d }
|
24
27
|
|
25
28
|
fail "No existing fixtures directory found in #{candidates.map { |d| format('"%s"', d) }.join(', ')}. " unless @fixtures_directory
|
26
29
|
end
|
27
30
|
|
28
|
-
fail %(Fixtures directory "#{@fixtures_directory}" is not a directory) unless Aruba
|
31
|
+
fail %(Fixtures directory "#{@fixtures_directory}" is not a directory) unless Aruba.platform.directory?(@fixtures_directory)
|
29
32
|
|
30
33
|
ArubaPath.new(@fixtures_directory)
|
31
34
|
end
|