aruba 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +72 -1
- data/CONTRIBUTING.md +11 -31
- data/README.md +1 -2
- data/exe/aruba +2 -2
- data/lib/aruba.rb +1 -1
- data/lib/aruba/api.rb +11 -12
- data/lib/aruba/api/bundler.rb +18 -3
- data/lib/aruba/api/commands.rb +19 -22
- data/lib/aruba/api/core.rb +65 -48
- data/lib/aruba/api/environment.rb +13 -5
- data/lib/aruba/api/filesystem.rb +69 -39
- data/lib/aruba/api/text.rb +15 -3
- data/lib/aruba/aruba_path.rb +3 -4
- data/lib/aruba/basic_configuration.rb +52 -71
- data/lib/aruba/basic_configuration/option.rb +2 -2
- data/lib/aruba/cli.rb +9 -6
- data/lib/aruba/command.rb +4 -4
- data/lib/aruba/config/jruby.rb +9 -9
- data/lib/aruba/config_wrapper.rb +17 -2
- data/lib/aruba/configuration.rb +37 -32
- data/lib/aruba/console.rb +11 -13
- data/lib/aruba/console/help.rb +9 -6
- data/lib/aruba/contracts/absolute_path.rb +2 -2
- data/lib/aruba/contracts/enum.rb +1 -1
- data/lib/aruba/contracts/is_power_of_two.rb +3 -3
- data/lib/aruba/contracts/relative_path.rb +2 -2
- data/lib/aruba/cucumber.rb +7 -7
- data/lib/aruba/cucumber/command.rb +106 -95
- data/lib/aruba/cucumber/environment.rb +7 -7
- data/lib/aruba/cucumber/file.rb +50 -26
- data/lib/aruba/cucumber/hooks.rb +32 -29
- data/lib/aruba/cucumber/testing_frameworks.rb +32 -30
- data/lib/aruba/event_bus.rb +6 -4
- data/lib/aruba/event_bus/name_resolver.rb +12 -11
- data/lib/aruba/events.rb +2 -1
- data/lib/aruba/file_size.rb +1 -1
- data/lib/aruba/generators/script_file.rb +2 -2
- data/lib/aruba/hooks.rb +2 -4
- data/lib/aruba/in_config_wrapper.rb +8 -5
- data/lib/aruba/initializer.rb +14 -12
- data/lib/aruba/matchers/base/base_matcher.rb +3 -12
- data/lib/aruba/matchers/base/message_indenter.rb +2 -2
- data/lib/aruba/matchers/base/object_formatter.rb +2 -5
- data/lib/aruba/matchers/collection.rb +1 -1
- data/lib/aruba/matchers/collection/all.rb +1 -1
- data/lib/aruba/matchers/collection/include_an_object.rb +6 -6
- data/lib/aruba/matchers/command.rb +1 -1
- data/lib/aruba/matchers/command/be_successfully_executed.rb +6 -4
- data/lib/aruba/matchers/command/have_exit_status.rb +3 -1
- data/lib/aruba/matchers/command/have_finished_in_time.rb +4 -2
- data/lib/aruba/matchers/command/have_output.rb +4 -2
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +3 -1
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +3 -1
- data/lib/aruba/matchers/directory.rb +1 -1
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +2 -2
- data/lib/aruba/matchers/directory/have_sub_directory.rb +9 -4
- data/lib/aruba/matchers/environment.rb +1 -1
- data/lib/aruba/matchers/file.rb +1 -1
- data/lib/aruba/matchers/file/be_a_command_found_in_path.rb +1 -1
- data/lib/aruba/matchers/file/be_an_existing_executable.rb +2 -2
- data/lib/aruba/matchers/file/be_an_existing_file.rb +2 -2
- data/lib/aruba/matchers/file/have_file_content.rb +1 -1
- data/lib/aruba/matchers/file/have_file_size.rb +5 -3
- data/lib/aruba/matchers/file/have_same_file_content.rb +2 -2
- data/lib/aruba/matchers/path.rb +1 -1
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +1 -1
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +1 -1
- data/lib/aruba/matchers/path/be_an_existing_path.rb +1 -1
- data/lib/aruba/matchers/path/have_permissions.rb +9 -6
- data/lib/aruba/matchers/string.rb +1 -1
- data/lib/aruba/matchers/string/include_output_string.rb +1 -1
- data/lib/aruba/matchers/string/match_output_string.rb +1 -1
- data/lib/aruba/matchers/string/output_string_eq.rb +1 -1
- data/lib/aruba/platform.rb +2 -2
- data/lib/aruba/platforms/announcer.rb +29 -17
- data/lib/aruba/platforms/aruba_file_creator.rb +3 -1
- data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +7 -2
- data/lib/aruba/platforms/aruba_logger.rb +11 -10
- data/lib/aruba/platforms/command_monitor.rb +7 -9
- data/lib/aruba/platforms/determine_disk_usage.rb +2 -4
- data/lib/aruba/platforms/filesystem_status.rb +20 -14
- data/lib/aruba/platforms/simple_table.rb +3 -3
- data/lib/aruba/platforms/unix_command_string.rb +2 -2
- data/lib/aruba/platforms/unix_environment_variables.rb +2 -4
- data/lib/aruba/platforms/unix_platform.rb +23 -23
- data/lib/aruba/platforms/unix_which.rb +2 -2
- data/lib/aruba/platforms/windows_command_string.rb +2 -2
- data/lib/aruba/platforms/windows_environment_variables.rb +3 -2
- data/lib/aruba/platforms/windows_platform.rb +7 -7
- data/lib/aruba/platforms/windows_which.rb +8 -4
- data/lib/aruba/processes/basic_process.rb +4 -4
- data/lib/aruba/processes/debug_process.rb +5 -3
- data/lib/aruba/processes/in_process.rb +10 -8
- data/lib/aruba/processes/spawn_process.rb +28 -25
- data/lib/aruba/rspec.rb +30 -20
- data/lib/aruba/runtime.rb +16 -9
- data/lib/aruba/setup.rb +25 -12
- data/lib/aruba/version.rb +1 -1
- metadata +77 -88
- data/.cucumberproignore +0 -3
- data/.document +0 -5
- data/.github/ISSUE_TEMPLATE.md +0 -48
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -41
- data/.gitignore +0 -38
- data/.rspec +0 -3
- data/.rubocop.yml +0 -31
- data/.rubocop_todo.yml +0 -262
- data/.simplecov +0 -36
- data/.travis.yml +0 -62
- data/.yardopts +0 -11
- data/Dockerfile +0 -67
- data/Gemfile +0 -12
- data/Rakefile +0 -80
- data/TODO.md +0 -13
- data/appveyor.yml +0 -29
- data/aruba.gemspec +0 -54
- data/bin/console +0 -7
- data/bin/test +0 -9
- data/config/.gitignore +0 -1
- data/cucumber.yml +0 -6
- data/docker-compose.yml +0 -26
- data/fixtures/cli-app/.gitignore +0 -9
- data/fixtures/cli-app/.rspec +0 -2
- data/fixtures/cli-app/README.md +0 -39
- data/fixtures/cli-app/Rakefile +0 -1
- data/fixtures/cli-app/bin/aruba-test-cli +0 -6
- data/fixtures/cli-app/cli-app.gemspec +0 -25
- data/fixtures/cli-app/features/support/aruba.rb +0 -1
- data/fixtures/cli-app/features/support/env.rb +0 -1
- data/fixtures/cli-app/lib/cli/app.rb +0 -9
- data/fixtures/cli-app/lib/cli/app/suppress_simple_cov_output.rb +0 -15
- data/fixtures/cli-app/lib/cli/app/version.rb +0 -5
- data/fixtures/cli-app/script/console +0 -14
- data/fixtures/cli-app/spec/spec_helper.rb +0 -7
- data/fixtures/cli-app/spec/support/aruba.rb +0 -1
- data/fixtures/copy/file.txt +0 -1
- data/fixtures/empty-app/.gitignore +0 -9
- data/fixtures/empty-app/.rspec +0 -2
- data/fixtures/empty-app/README.md +0 -24
- data/fixtures/empty-app/Rakefile +0 -1
- data/fixtures/empty-app/cli-app.gemspec +0 -25
- data/fixtures/empty-app/lib/cli/app.rb +0 -7
- data/fixtures/empty-app/lib/cli/app/version.rb +0 -5
- data/fixtures/getting-started-app/.gitignore +0 -4
- data/fixtures/getting-started-app/Gemfile +0 -4
- data/fixtures/getting-started-app/README.md +0 -3
- data/fixtures/getting-started-app/features/support/env.rb +0 -1
- data/lib/aruba/extensions/string/strip.rb +0 -25
- data/lib/aruba/tasks/docker_helpers.rb +0 -154
@@ -15,8 +15,8 @@ module Aruba
|
|
15
15
|
name = opts[:name]
|
16
16
|
value = opts[:value]
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
raise ArgumentError, '"name" is required' unless opts.key? :name
|
19
|
+
raise ArgumentError, '"value" is required' unless opts.key? :value
|
20
20
|
|
21
21
|
@name = name
|
22
22
|
@value = value
|
data/lib/aruba/cli.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "thor"
|
2
|
+
require "aruba/console"
|
3
|
+
require "aruba/initializer"
|
4
4
|
|
5
5
|
# Aruba
|
6
6
|
module Aruba
|
@@ -12,13 +12,16 @@ module Aruba
|
|
12
12
|
true
|
13
13
|
end
|
14
14
|
|
15
|
-
desc
|
15
|
+
desc "console", "Start aruba's console"
|
16
16
|
def console
|
17
17
|
Aruba::Console.new.start
|
18
18
|
end
|
19
19
|
|
20
|
-
desc
|
21
|
-
option :test_framework,
|
20
|
+
desc "init", "Initialize aruba"
|
21
|
+
option :test_framework,
|
22
|
+
default: "cucumber",
|
23
|
+
enum: %w(cucumber rspec minitest),
|
24
|
+
desc: "Choose which test framework to use"
|
22
25
|
def init
|
23
26
|
Aruba::Initializer.new.call(options[:test_framework])
|
24
27
|
end
|
data/lib/aruba/command.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "delegate"
|
2
|
+
require "aruba/processes/spawn_process"
|
3
|
+
require "aruba/processes/in_process"
|
4
|
+
require "aruba/processes/debug_process"
|
5
5
|
|
6
6
|
# Aruba
|
7
7
|
module Aruba
|
data/lib/aruba/config/jruby.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
require
|
1
|
+
require "rbconfig"
|
2
2
|
|
3
3
|
# ideas taken from: http://blog.headius.com/2010/03/jruby-startup-time-tips.html
|
4
4
|
Aruba.configure do |config|
|
5
5
|
config.before :command do |command|
|
6
|
-
next unless RUBY_PLATFORM ==
|
6
|
+
next unless RUBY_PLATFORM == "java"
|
7
7
|
|
8
8
|
env = command.environment
|
9
9
|
|
10
|
-
jruby_opts = env[
|
10
|
+
jruby_opts = env["JRUBY_OPTS"] || ""
|
11
11
|
|
12
12
|
# disable JIT since these processes are so short lived
|
13
|
-
jruby_opts = "-X-C #{jruby_opts}" unless jruby_opts.include?
|
13
|
+
jruby_opts = "-X-C #{jruby_opts}" unless jruby_opts.include? "-X-C"
|
14
14
|
|
15
15
|
# Faster startup for jruby
|
16
|
-
jruby_opts = "--dev #{jruby_opts}" unless jruby_opts.include?
|
16
|
+
jruby_opts = "--dev #{jruby_opts}" unless jruby_opts.include? "--dev"
|
17
17
|
|
18
|
-
env[
|
18
|
+
env["JRUBY_OPTS"] = jruby_opts
|
19
19
|
|
20
|
-
if /solaris|sunos/i.match?(RbConfig::CONFIG[
|
21
|
-
java_opts = env[
|
20
|
+
if /solaris|sunos/i.match?(RbConfig::CONFIG["host_os"])
|
21
|
+
java_opts = env["JAVA_OPTS"] || ""
|
22
22
|
|
23
23
|
# force jRuby to use client JVM for faster startup times
|
24
|
-
env[
|
24
|
+
env["JAVA_OPTS"] = "-d32 #{java_opts}" unless java_opts.include?("-d32")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
data/lib/aruba/config_wrapper.rb
CHANGED
@@ -30,9 +30,11 @@ module Aruba
|
|
30
30
|
# If one method ends with "=", e.g. ":option1=", then notify the event
|
31
31
|
# queue, that the user changes the value of "option1"
|
32
32
|
def method_missing(name, *args, &block)
|
33
|
-
|
33
|
+
notify(name, args) if name.to_s.end_with?("=")
|
34
34
|
|
35
|
-
config.send(name, *args, &block)
|
35
|
+
return config.send(name, *args, &block) if config.respond_to? name
|
36
|
+
|
37
|
+
super
|
36
38
|
end
|
37
39
|
|
38
40
|
# Pass on respond_to?-calls
|
@@ -54,5 +56,18 @@ module Aruba
|
|
54
56
|
def respond_to?(m)
|
55
57
|
config.respond_to? m
|
56
58
|
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def notify(name, args)
|
63
|
+
event_bus.notify(
|
64
|
+
Events::ChangedConfiguration.new(
|
65
|
+
changed: {
|
66
|
+
name: name.to_s.gsub(/=$/, ""),
|
67
|
+
value: args.first
|
68
|
+
}
|
69
|
+
)
|
70
|
+
)
|
71
|
+
end
|
57
72
|
end
|
58
73
|
end
|
data/lib/aruba/configuration.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require "contracts"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "aruba/version"
|
4
|
+
require "aruba/basic_configuration"
|
5
|
+
require "aruba/in_config_wrapper"
|
6
|
+
require "aruba/hooks"
|
7
7
|
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
8
|
+
require "aruba/contracts/relative_path"
|
9
|
+
require "aruba/contracts/absolute_path"
|
10
|
+
require "aruba/contracts/enum"
|
11
11
|
|
12
|
-
require
|
12
|
+
require "aruba/contracts/is_power_of_two"
|
13
13
|
|
14
14
|
# Aruba
|
15
15
|
module Aruba
|
@@ -17,54 +17,59 @@ module Aruba
|
|
17
17
|
#
|
18
18
|
# This defines the configuration options of aruba
|
19
19
|
class Configuration < BasicConfiguration
|
20
|
-
option_reader :root_directory,
|
20
|
+
option_reader :root_directory, type: String, default: Dir.getwd
|
21
21
|
|
22
22
|
option_accessor :working_directory,
|
23
|
-
|
24
|
-
default:
|
23
|
+
type: Aruba::Contracts::RelativePath,
|
24
|
+
default: "tmp/aruba"
|
25
25
|
|
26
|
-
option_reader :fixtures_path_prefix,
|
26
|
+
option_reader :fixtures_path_prefix, type: String, default: "%"
|
27
27
|
|
28
|
-
option_accessor :exit_timeout,
|
29
|
-
option_accessor :stop_signal,
|
30
|
-
option_accessor :io_wait_timeout,
|
31
|
-
option_accessor :startup_wait_time,
|
28
|
+
option_accessor :exit_timeout, type: Num, default: 15
|
29
|
+
option_accessor :stop_signal, type: Maybe[String], default: nil
|
30
|
+
option_accessor :io_wait_timeout, type: Num, default: 0.1
|
31
|
+
option_accessor :startup_wait_time, type: Num, default: 0
|
32
32
|
option_accessor :fixtures_directories,
|
33
|
-
|
33
|
+
type: ArrayOf[String],
|
34
34
|
default: %w(features/fixtures spec/fixtures test/fixtures fixtures)
|
35
35
|
|
36
|
-
option_accessor :command_runtime_environment,
|
36
|
+
option_accessor :command_runtime_environment, type: Hash, default: {}
|
37
37
|
option_accessor :command_search_paths,
|
38
|
-
|
39
|
-
[File.join(config.root_directory.value,
|
38
|
+
type: ArrayOf[String] do |config|
|
39
|
+
[File.join(config.root_directory.value, "bin"),
|
40
|
+
File.join(config.root_directory.value, "exe")]
|
40
41
|
end
|
41
|
-
option_accessor :remove_ansi_escape_sequences,
|
42
|
+
option_accessor :remove_ansi_escape_sequences, type: Bool, default: true
|
42
43
|
option_accessor :command_launcher,
|
43
|
-
|
44
|
+
type: Aruba::Contracts::Enum[:in_process, :spawn, :debug],
|
44
45
|
default: :spawn
|
45
|
-
option_accessor :main_class,
|
46
|
+
option_accessor :main_class, type: Maybe[Class], default: nil
|
46
47
|
|
47
48
|
option_accessor :home_directory,
|
48
|
-
|
49
|
-
|
49
|
+
type: Or[Aruba::Contracts::AbsolutePath,
|
50
|
+
Aruba::Contracts::RelativePath] do |config|
|
50
51
|
File.join(config.root_directory.value, config.working_directory.value)
|
51
52
|
end
|
52
53
|
|
53
54
|
option_accessor :log_level,
|
54
|
-
|
55
|
-
|
55
|
+
type:
|
56
|
+
Aruba::Contracts::Enum[:fatal, :warn, :debug, :info,
|
57
|
+
:error, :unknown, :silent],
|
56
58
|
default: :info
|
57
59
|
|
58
60
|
# TODO: deprecate this value and replace with "filesystem allocation unit"
|
59
61
|
# equal to 4096 by default. "filesystem allocation unit" would represent
|
60
62
|
# the actual MINIMUM space taken in bytes by a 1-byte file
|
61
63
|
option_accessor :physical_block_size,
|
62
|
-
|
64
|
+
type: Aruba::Contracts::IsPowerOfTwo,
|
63
65
|
default: 512
|
64
|
-
option_accessor :console_history_file,
|
66
|
+
option_accessor :console_history_file, type: String,
|
67
|
+
default: "~/.aruba_history"
|
65
68
|
|
66
|
-
option_accessor :activate_announcer_on_command_failure,
|
67
|
-
|
69
|
+
option_accessor :activate_announcer_on_command_failure,
|
70
|
+
type: ArrayOf[Symbol],
|
71
|
+
default: []
|
72
|
+
option_accessor :allow_absolute_paths, type: Bool, default: false
|
68
73
|
end
|
69
74
|
end
|
70
75
|
|
data/lib/aruba/console.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "irb"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "aruba/api"
|
4
|
+
require "aruba/console/help"
|
5
5
|
|
6
6
|
# Aruba
|
7
7
|
module Aruba
|
@@ -9,28 +9,27 @@ module Aruba
|
|
9
9
|
class Console
|
10
10
|
# Start the aruba console
|
11
11
|
#
|
12
|
-
# rubocop:disable Metrics/MethodLength
|
13
12
|
def start
|
14
13
|
# Start IRB with current context:
|
15
14
|
# http://stackoverflow.com/questions/4189818/how-to-run-irb-start-in-context-of-current-class
|
16
15
|
ARGV.clear
|
17
16
|
IRB.setup nil
|
18
17
|
|
19
|
-
IRB.conf[:IRB_NAME] =
|
18
|
+
IRB.conf[:IRB_NAME] = "aruba"
|
20
19
|
|
21
20
|
IRB.conf[:PROMPT] = {}
|
22
21
|
IRB.conf[:PROMPT][:ARUBA] = {
|
23
|
-
PROMPT_I:
|
24
|
-
PROMPT_S:
|
25
|
-
PROMPT_C:
|
22
|
+
PROMPT_I: "%N:%03n:%i> ",
|
23
|
+
PROMPT_S: "%N:%03n:%i%l ",
|
24
|
+
PROMPT_C: "%N:%03n:%i* ",
|
26
25
|
RETURN: "# => %s\n"
|
27
26
|
}
|
28
27
|
IRB.conf[:PROMPT_MODE] = :ARUBA
|
29
28
|
|
30
29
|
IRB.conf[:RC] = false
|
31
30
|
|
32
|
-
require
|
33
|
-
require
|
31
|
+
require "irb/completion"
|
32
|
+
require "irb/ext/save-history"
|
34
33
|
IRB.conf[:READLINE] = true
|
35
34
|
IRB.conf[:SAVE_HISTORY] = 1000
|
36
35
|
IRB.conf[:HISTORY_FILE] = Aruba.config.console_history_file
|
@@ -44,14 +43,14 @@ module Aruba
|
|
44
43
|
end
|
45
44
|
|
46
45
|
def inspect
|
47
|
-
|
46
|
+
"nil"
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
50
|
irb = IRB::Irb.new(IRB::WorkSpace.new(context.new))
|
52
51
|
IRB.conf[:MAIN_CONTEXT] = irb.context
|
53
52
|
|
54
|
-
trap(
|
53
|
+
trap("SIGINT") do
|
55
54
|
irb.signal_handle
|
56
55
|
end
|
57
56
|
|
@@ -63,6 +62,5 @@ module Aruba
|
|
63
62
|
IRB.irb_at_exit
|
64
63
|
end
|
65
64
|
end
|
66
|
-
# rubocop:enable Metrics/MethodLength
|
67
65
|
end
|
68
66
|
end
|
data/lib/aruba/console/help.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "aruba/api"
|
2
2
|
|
3
3
|
# Aruba
|
4
4
|
module Aruba
|
@@ -8,9 +8,10 @@ module Aruba
|
|
8
8
|
module Help
|
9
9
|
# Output help information
|
10
10
|
def aruba_help
|
11
|
-
puts
|
12
|
-
puts
|
13
|
-
puts "Documentation
|
11
|
+
puts "Aruba Version: #{Aruba::VERSION}"
|
12
|
+
puts "Issue Tracker: https://github.com/cucumber/aruba/issues"
|
13
|
+
puts "Documentation:"
|
14
|
+
puts "* http://www.rubydoc.info/gems/aruba"
|
14
15
|
puts
|
15
16
|
|
16
17
|
nil
|
@@ -18,9 +19,11 @@ module Aruba
|
|
18
19
|
|
19
20
|
# List available methods in aruba
|
20
21
|
def aruba_methods
|
21
|
-
ms = (Aruba::Api.instance_methods - Module.instance_methods)
|
22
|
+
ms = (Aruba::Api.instance_methods - Module.instance_methods)
|
23
|
+
.each_with_object([]) { |e, a| a << format("* %s", e) }
|
24
|
+
.sort
|
22
25
|
|
23
|
-
puts "Available Methods:\n
|
26
|
+
puts "Available Methods:\n#{ms.join("\n")}"
|
24
27
|
|
25
28
|
nil
|
26
29
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "aruba/platform"
|
2
2
|
|
3
3
|
# Aruba
|
4
4
|
module Aruba
|
@@ -12,7 +12,7 @@ module Aruba
|
|
12
12
|
# The value to be checked
|
13
13
|
def self.valid?(value)
|
14
14
|
Aruba.platform.absolute_path? value
|
15
|
-
rescue
|
15
|
+
rescue StandardError
|
16
16
|
false
|
17
17
|
end
|
18
18
|
end
|
data/lib/aruba/contracts/enum.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "aruba/aruba_path"
|
2
2
|
|
3
3
|
# Aruba
|
4
4
|
module Aruba
|
@@ -13,8 +13,8 @@ module Aruba
|
|
13
13
|
def self.valid?(value)
|
14
14
|
# explanation for algorithm can be found here:
|
15
15
|
# http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/
|
16
|
-
value
|
17
|
-
rescue
|
16
|
+
value.positive? && (value & (value - 1)).zero?
|
17
|
+
rescue StandardError
|
18
18
|
false
|
19
19
|
end
|
20
20
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "aruba/platform"
|
2
2
|
|
3
3
|
# Aruba
|
4
4
|
module Aruba
|
@@ -12,7 +12,7 @@ module Aruba
|
|
12
12
|
# The path to be checked
|
13
13
|
def self.valid?(value)
|
14
14
|
Aruba.platform.relative_path? value
|
15
|
-
rescue
|
15
|
+
rescue StandardError
|
16
16
|
false
|
17
17
|
end
|
18
18
|
end
|
data/lib/aruba/cucumber.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require "aruba/version"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
3
|
+
require "aruba/api"
|
4
|
+
require "aruba/cucumber/hooks"
|
5
|
+
require "aruba/cucumber/command"
|
6
|
+
require "aruba/cucumber/environment"
|
7
|
+
require "aruba/cucumber/file"
|
8
|
+
require "aruba/cucumber/testing_frameworks"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "aruba/generators/script_file"
|
2
2
|
|
3
3
|
When(/^I run `([^`]*)`$/) do |cmd|
|
4
4
|
cmd = sanitize_text(cmd)
|
@@ -12,10 +12,11 @@ When(/^I successfully run `(.*?)`(?: for up to ([\d.]+) seconds)?$/) do |cmd, se
|
|
12
12
|
run_command_and_stop(cmd, fail_on_error: true, exit_timeout: secs && secs.to_f)
|
13
13
|
end
|
14
14
|
|
15
|
-
When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/)
|
16
|
-
|
15
|
+
When(/^I run the following (?:commands|script)(?: (?:with|in) `([^`]+)`)?:$/) \
|
16
|
+
do |shell, commands|
|
17
|
+
full_path = expand_path("bin/myscript")
|
17
18
|
|
18
|
-
Aruba.platform.mkdir(expand_path(
|
19
|
+
Aruba.platform.mkdir(expand_path("bin"))
|
19
20
|
shell ||= Aruba.platform.default_shell
|
20
21
|
|
21
22
|
Aruba::ScriptFile.new(interpreter: shell, content: commands, path: full_path).call
|
@@ -54,14 +55,15 @@ When(/^I (terminate|stop) the command (?:"([^"]*)"|(?:started last))$/) do |sign
|
|
54
55
|
last_command_started
|
55
56
|
end
|
56
57
|
|
57
|
-
if signal ==
|
58
|
+
if signal == "terminate"
|
58
59
|
cmd.terminate
|
59
60
|
else
|
60
61
|
cmd.stop
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
64
|
-
When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/)
|
65
|
+
When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$/) \
|
66
|
+
do |channel, expected|
|
65
67
|
begin
|
66
68
|
Timeout.timeout(aruba.config.exit_timeout) do
|
67
69
|
loop do
|
@@ -86,30 +88,22 @@ end
|
|
86
88
|
|
87
89
|
When(/^I wait for (?:output|stdout) to contain:$/) do |expected|
|
88
90
|
Timeout.timeout(aruba.config.exit_timeout) do
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
retry
|
95
|
-
end
|
96
|
-
|
97
|
-
break
|
91
|
+
begin
|
92
|
+
expect(last_command_started).to have_output an_output_string_including(expected)
|
93
|
+
rescue ExpectationError
|
94
|
+
sleep 0.1
|
95
|
+
retry
|
98
96
|
end
|
99
97
|
end
|
100
98
|
end
|
101
99
|
|
102
100
|
When(/^I wait for (?:output|stdout) to contain "([^"]*)"$/) do |expected|
|
103
101
|
Timeout.timeout(aruba.config.exit_timeout) do
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
retry
|
110
|
-
end
|
111
|
-
|
112
|
-
break
|
102
|
+
begin
|
103
|
+
expect(last_command_started).to have_output an_output_string_including(expected)
|
104
|
+
rescue ExpectationError
|
105
|
+
sleep 0.1
|
106
|
+
retry
|
113
107
|
end
|
114
108
|
end
|
115
109
|
end
|
@@ -119,7 +113,8 @@ Then(/^the output should be (\d+) bytes long$/) do |size|
|
|
119
113
|
end
|
120
114
|
|
121
115
|
## the stderr should contain "hello"
|
122
|
-
Then(/^(?:the )?(output|stderr|stdout) should( not)? contain( exactly)? "([^"]*)"$/)
|
116
|
+
Then(/^(?:the )?(output|stderr|stdout) should( not)? contain( exactly)? "([^"]*)"$/) \
|
117
|
+
do |channel, negated, exactly, expected|
|
123
118
|
combined_output = send("all_#{channel}")
|
124
119
|
|
125
120
|
output_string_matcher = if exactly
|
@@ -136,14 +131,13 @@ Then(/^(?:the )?(output|stderr|stdout) should( not)? contain( exactly)? "([^"]*)
|
|
136
131
|
end
|
137
132
|
|
138
133
|
## the stderr from "echo -n 'Hello'" should contain "hello"
|
139
|
-
Then(
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
when :
|
144
|
-
|
145
|
-
when :
|
146
|
-
:have_output_on_stdout
|
134
|
+
Then(
|
135
|
+
/^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)? "([^"]*)"$/
|
136
|
+
) do |channel, cmd, exactly, expected|
|
137
|
+
matcher = case channel
|
138
|
+
when "output"; then :have_output
|
139
|
+
when "stderr"; then :have_output_on_stderr
|
140
|
+
when "stdout"; then :have_output_on_stdout
|
147
141
|
end
|
148
142
|
|
149
143
|
command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
|
@@ -154,15 +148,33 @@ Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should( not)? contain( exa
|
|
154
148
|
:an_output_string_including
|
155
149
|
end
|
156
150
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
151
|
+
expect(command).to send(matcher, send(output_string_matcher, expected))
|
152
|
+
end
|
153
|
+
|
154
|
+
## the stderr from "echo -n 'Hello'" should not contain "hello"
|
155
|
+
Then(
|
156
|
+
/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)? "([^"]*)"$/
|
157
|
+
) do |channel, cmd, exactly, expected|
|
158
|
+
matcher = case channel
|
159
|
+
when "output"; then :have_output
|
160
|
+
when "stderr"; then :have_output_on_stderr
|
161
|
+
when "stdout"; then :have_output_on_stdout
|
162
|
+
end
|
163
|
+
|
164
|
+
command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
|
165
|
+
|
166
|
+
output_string_matcher = if exactly
|
167
|
+
:an_output_string_being_eq
|
168
|
+
else
|
169
|
+
:an_output_string_including
|
170
|
+
end
|
171
|
+
|
172
|
+
expect(command).not_to send(matcher, send(output_string_matcher, expected))
|
162
173
|
end
|
163
174
|
|
164
175
|
## the stderr should not contain exactly:
|
165
|
-
Then(/^(?:the )?(output|stderr|stdout) should not contain( exactly)?:$/)
|
176
|
+
Then(/^(?:the )?(output|stderr|stdout) should not contain( exactly)?:$/) \
|
177
|
+
do |channel, exactly, expected|
|
166
178
|
combined_output = send("all_#{channel}")
|
167
179
|
|
168
180
|
output_string_matcher = if exactly
|
@@ -175,7 +187,8 @@ Then(/^(?:the )?(output|stderr|stdout) should not contain( exactly)?:$/) do |cha
|
|
175
187
|
end
|
176
188
|
|
177
189
|
## the stderr should contain exactly:
|
178
|
-
Then(/^(?:the )?(output|stderr|stdout) should contain( exactly)?:$/)
|
190
|
+
Then(/^(?:the )?(output|stderr|stdout) should contain( exactly)?:$/) \
|
191
|
+
do |channel, exactly, expected|
|
179
192
|
combined_output = send("all_#{channel}")
|
180
193
|
|
181
194
|
output_string_matcher = if exactly
|
@@ -188,14 +201,12 @@ Then(/^(?:the )?(output|stderr|stdout) should contain( exactly)?:$/) do |channel
|
|
188
201
|
end
|
189
202
|
|
190
203
|
## the stderr from "echo -n 'Hello'" should not contain exactly:
|
191
|
-
Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)?:$/)
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
when :
|
196
|
-
|
197
|
-
when :stdout
|
198
|
-
:have_output_on_stdout
|
204
|
+
Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactly)?:$/) \
|
205
|
+
do |channel, cmd, exactly, expected|
|
206
|
+
matcher = case channel
|
207
|
+
when "output"; then :have_output
|
208
|
+
when "stderr"; then :have_output_on_stderr
|
209
|
+
when "stdout"; then :have_output_on_stdout
|
199
210
|
end
|
200
211
|
|
201
212
|
command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
|
@@ -210,14 +221,12 @@ Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should not contain( exactl
|
|
210
221
|
end
|
211
222
|
|
212
223
|
## the stderr from "echo -n 'Hello'" should contain exactly:
|
213
|
-
Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)?:$/)
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
when :
|
218
|
-
|
219
|
-
when :stdout
|
220
|
-
:have_output_on_stdout
|
224
|
+
Then(/^(?:the )?(output|stderr|stdout) from "([^"]*)" should contain( exactly)?:$/) \
|
225
|
+
do |channel, cmd, exactly, expected|
|
226
|
+
matcher = case channel
|
227
|
+
when "output"; then :have_output
|
228
|
+
when "stderr"; then :have_output_on_stderr
|
229
|
+
when "stdout"; then :have_output_on_stdout
|
221
230
|
end
|
222
231
|
|
223
232
|
command = aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))
|
@@ -235,34 +244,38 @@ end
|
|
235
244
|
# you don't need regex, use "the output should contain" instead since
|
236
245
|
# that way, you don't have to escape regex characters that
|
237
246
|
# appear naturally in the output
|
238
|
-
Then(
|
247
|
+
Then(%r{^the output should( not)? match /([^/]*)/$}) do |negated, expected|
|
239
248
|
if negated
|
240
|
-
expect(all_commands)
|
249
|
+
expect(all_commands)
|
250
|
+
.not_to include_an_object have_output an_output_string_matching(expected)
|
241
251
|
else
|
242
|
-
expect(all_commands)
|
252
|
+
expect(all_commands)
|
253
|
+
.to include_an_object have_output an_output_string_matching(expected)
|
243
254
|
end
|
244
255
|
end
|
245
256
|
|
246
257
|
Then(/^the output should( not)? match %r<([^>]*)>$/) do |negated, expected|
|
247
258
|
if negated
|
248
|
-
expect(all_commands)
|
259
|
+
expect(all_commands)
|
260
|
+
.not_to include_an_object have_output an_output_string_matching(expected)
|
249
261
|
else
|
250
|
-
expect(all_commands)
|
262
|
+
expect(all_commands)
|
263
|
+
.to include_an_object have_output an_output_string_matching(expected)
|
251
264
|
end
|
252
265
|
end
|
253
266
|
|
254
267
|
Then(/^the output should( not)? match:$/) do |negated, expected|
|
255
268
|
if negated
|
256
|
-
expect(all_commands)
|
269
|
+
expect(all_commands)
|
270
|
+
.not_to include_an_object have_output an_output_string_matching(expected)
|
257
271
|
else
|
258
|
-
expect(all_commands)
|
272
|
+
expect(all_commands)
|
273
|
+
.to include_an_object have_output an_output_string_matching(expected)
|
259
274
|
end
|
260
275
|
end
|
261
276
|
|
262
277
|
Then(/^the exit status should( not)? be (\d+)$/) do |negated, exit_status|
|
263
|
-
if last_command_stopped.nil?
|
264
|
-
last_command_started.stop
|
265
|
-
end
|
278
|
+
last_command_started.stop if last_command_stopped.nil?
|
266
279
|
|
267
280
|
if negated
|
268
281
|
expect(last_command_stopped).not_to have_exit_status exit_status.to_i
|
@@ -274,7 +287,7 @@ end
|
|
274
287
|
Then(/^it should not (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
|
275
288
|
last_command_started.stop
|
276
289
|
|
277
|
-
if pass_fail ==
|
290
|
+
if pass_fail == "pass"
|
278
291
|
expect(last_command_stopped).to be_successfully_executed
|
279
292
|
else
|
280
293
|
expect(last_command_stopped).not_to be_successfully_executed
|
@@ -286,7 +299,7 @@ end
|
|
286
299
|
Then(/^it should (pass|fail) with "(.*?)"$/) do |pass_fail, expected|
|
287
300
|
last_command_started.stop
|
288
301
|
|
289
|
-
if pass_fail ==
|
302
|
+
if pass_fail == "pass"
|
290
303
|
expect(last_command_stopped).to be_successfully_executed
|
291
304
|
else
|
292
305
|
expect(last_command_stopped).not_to be_successfully_executed
|
@@ -298,7 +311,7 @@ end
|
|
298
311
|
Then(/^it should not (pass|fail) with:$/) do |pass_fail, expected|
|
299
312
|
last_command_started.stop
|
300
313
|
|
301
|
-
if pass_fail ==
|
314
|
+
if pass_fail == "pass"
|
302
315
|
expect(last_command_stopped).to be_successfully_executed
|
303
316
|
else
|
304
317
|
expect(last_command_stopped).not_to be_successfully_executed
|
@@ -310,7 +323,7 @@ end
|
|
310
323
|
Then(/^it should (pass|fail) with:$/) do |pass_fail, expected|
|
311
324
|
last_command_started.stop
|
312
325
|
|
313
|
-
if pass_fail ==
|
326
|
+
if pass_fail == "pass"
|
314
327
|
expect(last_command_stopped).to be_successfully_executed
|
315
328
|
else
|
316
329
|
expect(last_command_stopped).not_to be_successfully_executed
|
@@ -322,7 +335,7 @@ end
|
|
322
335
|
Then(/^it should not (pass|fail) with exactly:$/) do |pass_fail, expected|
|
323
336
|
last_command_started.stop
|
324
337
|
|
325
|
-
if pass_fail ==
|
338
|
+
if pass_fail == "pass"
|
326
339
|
expect(last_command_stopped).to be_successfully_executed
|
327
340
|
else
|
328
341
|
expect(last_command_stopped).not_to be_successfully_executed
|
@@ -334,7 +347,7 @@ end
|
|
334
347
|
Then(/^it should (pass|fail) with exactly:$/) do |pass_fail, expected|
|
335
348
|
last_command_started.stop
|
336
349
|
|
337
|
-
if pass_fail ==
|
350
|
+
if pass_fail == "pass"
|
338
351
|
expect(last_command_stopped).to be_successfully_executed
|
339
352
|
else
|
340
353
|
expect(last_command_stopped).not_to be_successfully_executed
|
@@ -346,7 +359,7 @@ end
|
|
346
359
|
Then(/^it should not (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
|
347
360
|
last_command_started.stop
|
348
361
|
|
349
|
-
if pass_fail ==
|
362
|
+
if pass_fail == "pass"
|
350
363
|
expect(last_command_stopped).to be_successfully_executed
|
351
364
|
else
|
352
365
|
expect(last_command_stopped).not_to be_successfully_executed
|
@@ -358,7 +371,7 @@ end
|
|
358
371
|
Then(/^it should (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expected|
|
359
372
|
last_command_started.stop
|
360
373
|
|
361
|
-
if pass_fail ==
|
374
|
+
if pass_fail == "pass"
|
362
375
|
expect(last_command_stopped).to be_successfully_executed
|
363
376
|
else
|
364
377
|
expect(last_command_stopped).not_to be_successfully_executed
|
@@ -368,35 +381,32 @@ Then(/^it should (pass|fail) (?:with regexp?|matching):$/) do |pass_fail, expect
|
|
368
381
|
end
|
369
382
|
|
370
383
|
Then(/^(?:the )?(output|stderr|stdout) should not contain anything$/) do |channel|
|
371
|
-
matcher = case channel
|
372
|
-
when :
|
373
|
-
|
374
|
-
when :
|
375
|
-
:have_output_on_stderr
|
376
|
-
when :stdout
|
377
|
-
:have_output_on_stdout
|
384
|
+
matcher = case channel
|
385
|
+
when "output"; then :have_output
|
386
|
+
when "stderr"; then :have_output_on_stderr
|
387
|
+
when "stdout"; then :have_output_on_stdout
|
378
388
|
end
|
379
389
|
|
380
390
|
expect(all_commands).to include_an_object send(matcher, be_nil.or(be_empty))
|
381
391
|
end
|
382
392
|
|
383
|
-
Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/)
|
393
|
+
Then(/^(?:the )?(output|stdout|stderr) should( not)? contain all of these lines:$/) \
|
394
|
+
do |channel, negated, table|
|
384
395
|
table.raw.flatten.each do |expected|
|
385
|
-
case channel
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
when :stdout
|
391
|
-
:have_output_on_stdout
|
392
|
-
end
|
396
|
+
_matcher = case channel
|
397
|
+
when "output"; then :have_output
|
398
|
+
when "stderr"; then :have_output_on_stderr
|
399
|
+
when "stdout"; then :have_output_on_stdout
|
400
|
+
end
|
393
401
|
|
394
402
|
# TODO: This isn't actually using the above. It's hardcoded to use have_output only
|
395
403
|
|
396
404
|
if negated
|
397
|
-
expect(all_commands)
|
405
|
+
expect(all_commands)
|
406
|
+
.not_to include_an_object have_output an_output_string_including(expected)
|
398
407
|
else
|
399
|
-
expect(all_commands)
|
408
|
+
expect(all_commands)
|
409
|
+
.to include_an_object have_output an_output_string_including(expected)
|
400
410
|
end
|
401
411
|
end
|
402
412
|
end
|
@@ -417,10 +427,11 @@ Given(/^I wait ([\d.]+) seconds? for (?:a|the) command to start up$/) do |second
|
|
417
427
|
aruba.config.startup_wait_time = seconds.to_f
|
418
428
|
end
|
419
429
|
|
420
|
-
When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/)
|
430
|
+
When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))$/) \
|
431
|
+
do |signal, command|
|
421
432
|
if command
|
422
433
|
cmd = all_commands.find { |c| c.commandline == command }
|
423
|
-
|
434
|
+
raise ArgumentError, %(No command "#{command}" found) if cmd.nil?
|
424
435
|
|
425
436
|
cmd.send_signal signal
|
426
437
|
else
|
@@ -429,5 +440,5 @@ When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))
|
|
429
440
|
end
|
430
441
|
|
431
442
|
Given(/^I look for executables in "(.*)" within the current directory$/) do |directory|
|
432
|
-
prepend_environment_variable
|
443
|
+
prepend_environment_variable "PATH", expand_path(directory) + File::PATH_SEPARATOR
|
433
444
|
end
|