aruba 0.7.4 → 0.8.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.nav +12 -0
- data/.rspec +1 -0
- data/.rubocop.yml +12 -0
- data/.simplecov +2 -0
- data/.travis.yml +5 -6
- data/Gemfile +53 -26
- data/History.md +17 -0
- data/LICENSE +1 -1
- data/README.md +45 -19
- data/Rakefile +12 -2
- data/TODO.md +3 -0
- data/aruba.gemspec +19 -8
- data/cucumber.yml +1 -1
- data/features/api/cd.feature +119 -0
- data/features/api/command/run.feature +37 -0
- data/features/api/command/which.feature +37 -0
- data/features/api/environment/append_environment_variable.feature +118 -0
- data/features/api/environment/prepend_environment_variable.feature +118 -0
- data/features/api/environment/set_environment_variable.feature +252 -0
- data/features/configuration/exit_timeout.feature +51 -0
- data/features/configuration/fixtures_directories.feature +31 -0
- data/features/configuration/fixtures_path_prefix.feature +24 -0
- data/features/configuration/io_timeout.feature +31 -0
- data/features/configuration/keep_ansi.feature +31 -0
- data/features/configuration/root_directory.feature +31 -0
- data/features/configuration/working_directory.feature +32 -0
- data/features/fixtures/cli-app/.gitignore +9 -0
- data/features/fixtures/cli-app/.rspec +2 -0
- data/features/fixtures/cli-app/README.md +34 -0
- data/features/fixtures/cli-app/Rakefile +1 -0
- data/features/fixtures/cli-app/bin/cli +6 -0
- data/features/fixtures/cli-app/cli-app.gemspec +26 -0
- data/features/fixtures/cli-app/features/support/env.rb +1 -0
- data/features/fixtures/cli-app/lib/cli/app.rb +13 -0
- data/features/fixtures/cli-app/lib/cli/app/version.rb +5 -0
- data/features/fixtures/cli-app/script/console +14 -0
- data/features/fixtures/cli-app/spec/cli/app_spec.rb +7 -0
- data/features/fixtures/cli-app/spec/spec_helper.rb +10 -0
- data/features/fixtures/copy/file.txt +1 -1
- data/features/hooks/after/command.feature +34 -0
- data/features/hooks/before/command.feature +61 -0
- data/features/matchers/directory/have_sub_directory.feature +110 -0
- data/features/matchers/file/be_existing_file.feature +82 -0
- data/features/matchers/file/have_file_content.feature +123 -0
- data/features/matchers/file/have_file_size.feature +107 -0
- data/features/matchers/path/be_an_absolute_path.feature +74 -0
- data/features/matchers/path/be_an_existing_path.feature +97 -0
- data/features/matchers/path/have_permissions.feature +118 -0
- data/features/matchers/timeouts.feature +48 -0
- data/features/step_definitions/aruba_dev_steps.rb +69 -1
- data/features/steps/commands/exit_statuses.feature +136 -0
- data/features/steps/commands/in_process.feature +129 -0
- data/features/steps/commands/run.feature +36 -0
- data/features/steps/environment/home_variable.feature +49 -0
- data/features/steps/environment/set_environment_variable.feature +34 -0
- data/features/support/aruba.rb +5 -0
- data/features/support/env.rb +8 -4
- data/lib/aruba.rb +20 -8
- data/lib/aruba/announcer.rb +1 -0
- data/lib/aruba/api.rb +18 -1179
- data/lib/aruba/api/command.rb +351 -0
- data/lib/aruba/api/core.rb +141 -0
- data/lib/aruba/api/deprecated.rb +549 -0
- data/lib/aruba/api/environment.rb +61 -0
- data/lib/aruba/api/filesystem.rb +305 -0
- data/lib/aruba/api/rvm.rb +39 -0
- data/lib/aruba/aruba_path.rb +75 -0
- data/lib/aruba/basic_configuration.rb +208 -0
- data/lib/aruba/basic_configuration/option.rb +25 -0
- data/lib/aruba/config.rb +43 -30
- data/lib/aruba/config/jruby.rb +14 -0
- data/lib/aruba/config_wrapper.rb +17 -0
- data/lib/aruba/contracts/relative_path.rb +13 -0
- data/lib/aruba/creators/aruba_file_creator.rb +32 -0
- data/lib/aruba/creators/aruba_fixed_size_file_creator.rb +32 -0
- data/lib/aruba/cucumber.rb +87 -53
- data/lib/aruba/cucumber/hooks.rb +65 -10
- data/lib/aruba/environment.rb +121 -0
- data/lib/aruba/errors.rb +3 -0
- data/lib/aruba/extensions/string/strip.rb +24 -0
- data/lib/aruba/hooks.rb +54 -0
- data/lib/aruba/jruby.rb +4 -9
- data/lib/aruba/matchers/command.rb +1 -79
- data/lib/aruba/matchers/command/be_successfully_executed.rb +30 -0
- data/lib/aruba/matchers/command/have_exit_status.rb +47 -0
- data/lib/aruba/matchers/command/have_finished_in_time.rb +42 -0
- data/lib/aruba/matchers/directory.rb +1 -59
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +34 -0
- data/lib/aruba/matchers/directory/have_sub_directory.rb +49 -0
- data/lib/aruba/matchers/file.rb +1 -177
- data/lib/aruba/matchers/file/be_an_existing_file.rb +34 -0
- data/lib/aruba/matchers/file/have_file_content.rb +58 -0
- data/lib/aruba/matchers/file/have_file_size.rb +43 -0
- data/lib/aruba/matchers/file/have_same_file_content.rb +44 -0
- data/lib/aruba/matchers/path.rb +1 -99
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +21 -0
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +32 -0
- data/lib/aruba/matchers/path/be_an_existing_path.rb +33 -0
- data/lib/aruba/matchers/path/have_permissions.rb +60 -0
- data/lib/aruba/matchers/path/match_path_pattern.rb +41 -0
- data/lib/aruba/matchers/rspec.rb +0 -0
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
- data/lib/aruba/platform.rb +230 -0
- data/lib/aruba/process_monitor.rb +23 -5
- data/lib/aruba/processes/basic_process.rb +35 -1
- data/lib/aruba/processes/debug_process.rb +26 -15
- data/lib/aruba/processes/in_process.rb +21 -9
- data/lib/aruba/processes/spawn_process.rb +29 -19
- data/lib/aruba/reporting.rb +2 -0
- data/lib/aruba/rspec.rb +61 -13
- data/lib/aruba/runtime.rb +33 -0
- data/script/bootstrap +4 -6
- data/spec/aruba/api/runtime_spec.rb +28 -0
- data/spec/aruba/api_spec.rb +129 -126
- data/spec/aruba/aruba_path_spec.rb +65 -0
- data/spec/aruba/basic_configuration_spec.rb +5 -0
- data/spec/aruba/config_wrapper_spec.rb +25 -0
- data/spec/aruba/configuration_spec.rb +5 -0
- data/spec/aruba/jruby_spec.rb +34 -18
- data/spec/aruba/matchers/directory_spec.rb +6 -7
- data/spec/aruba/matchers/file_spec.rb +16 -20
- data/spec/aruba/matchers/path_spec.rb +14 -11
- data/spec/aruba/rspec_spec.rb +15 -0
- data/spec/aruba/runtime_spec.rb +29 -0
- data/spec/aruba/spawn_process_spec.rb +2 -2
- data/spec/spec_helper.rb +10 -2
- data/spec/support/configs/rspec.rb +1 -1
- data/spec/support/matchers/option.rb +35 -0
- data/spec/support/shared_contexts/aruba.rb +10 -8
- data/spec/support/shared_examples/configuration.rb +116 -0
- metadata +182 -33
- data/.rvmrc +0 -1
- data/features/before_cmd_hooks.feature +0 -61
- data/features/command_environment_variables.feature +0 -31
- data/features/custom_ruby_process.feature +0 -12
- data/features/exit_statuses.feature +0 -30
- data/features/support/custom_main.rb +0 -28
- data/lib/aruba/matchers/mode.rb +0 -52
- data/lib/aruba/utils.rb +0 -21
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm @cucumber
|
@@ -1,61 +0,0 @@
|
|
1
|
-
Feature: before_cmd hooks
|
2
|
-
|
3
|
-
You can configure Aruba to run blocks of code before it runs
|
4
|
-
each command.
|
5
|
-
|
6
|
-
The command will be passed to the block.
|
7
|
-
|
8
|
-
Scenario: Run a simple command with a before hook
|
9
|
-
Given a file named "test.rb" with:
|
10
|
-
"""
|
11
|
-
$: << '../../lib'
|
12
|
-
require 'aruba/api'
|
13
|
-
|
14
|
-
Aruba.configure do |config|
|
15
|
-
config.before_cmd do |cmd|
|
16
|
-
puts "about to run `#{cmd}`"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
include Aruba::Api
|
21
|
-
run_simple("echo 'running'")
|
22
|
-
puts all_stdout
|
23
|
-
"""
|
24
|
-
When I run `ruby test.rb`
|
25
|
-
Then it should pass with:
|
26
|
-
"""
|
27
|
-
about to run `echo 'running'`
|
28
|
-
running
|
29
|
-
"""
|
30
|
-
|
31
|
-
# This should move into a spec
|
32
|
-
Scenario: Use something from the context where the command was run
|
33
|
-
Given a file named "test.rb" with:
|
34
|
-
"""
|
35
|
-
$: << '../../lib'
|
36
|
-
require 'aruba/api'
|
37
|
-
|
38
|
-
Aruba.configure do |config|
|
39
|
-
config.before_cmd do |cmd|
|
40
|
-
puts "I can see @your_context=#{@your_context}"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
class Test
|
45
|
-
include Aruba::Api
|
46
|
-
|
47
|
-
def test
|
48
|
-
@your_context = "something"
|
49
|
-
run_simple("echo 'running'")
|
50
|
-
puts all_stdout
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
Test.new.test
|
55
|
-
"""
|
56
|
-
When I run `ruby test.rb`
|
57
|
-
Then it should pass with:
|
58
|
-
"""
|
59
|
-
I can see @your_context=something
|
60
|
-
running
|
61
|
-
"""
|
@@ -1,31 +0,0 @@
|
|
1
|
-
Feature: Command environment variables
|
2
|
-
|
3
|
-
In order to test command line applications which make use of environment variables
|
4
|
-
As a developer using Cucumber
|
5
|
-
I want to use the command environment variable step
|
6
|
-
|
7
|
-
Scenario: Changing the environment
|
8
|
-
Given I set the environment variables to:
|
9
|
-
| variable | value |
|
10
|
-
| LONG_LONG_VARIABLE | long_value |
|
11
|
-
When I run `/usr/bin/env`
|
12
|
-
Then the output should contain:
|
13
|
-
"""
|
14
|
-
long_value
|
15
|
-
"""
|
16
|
-
|
17
|
-
Scenario: Mocked home directory
|
18
|
-
Given a mocked home directory
|
19
|
-
When I run `/usr/bin/env`
|
20
|
-
Then the output should contain:
|
21
|
-
"""
|
22
|
-
tmp/aruba
|
23
|
-
"""
|
24
|
-
|
25
|
-
@mocked_home_directory
|
26
|
-
Scenario: Mocked home directory
|
27
|
-
When I run `/usr/bin/env`
|
28
|
-
Then the output should contain:
|
29
|
-
"""
|
30
|
-
tmp/aruba
|
31
|
-
"""
|
@@ -1,12 +0,0 @@
|
|
1
|
-
Feature: Custom Ruby Process
|
2
|
-
|
3
|
-
Running a lot of scenarios where each scenario uses Aruba
|
4
|
-
to spawn a new ruby process can be time consuming.
|
5
|
-
|
6
|
-
Aruba lets you plug in your own process class that can
|
7
|
-
run a command in the same ruby process as Cucumber/Aruba.
|
8
|
-
|
9
|
-
@in-process
|
10
|
-
Scenario: Run a passing custom process
|
11
|
-
When I run `reverse olleh dlrow`
|
12
|
-
Then the output should contain "hello world"
|
@@ -1,30 +0,0 @@
|
|
1
|
-
Feature: exit statuses
|
2
|
-
|
3
|
-
In order to specify expected exit statuses
|
4
|
-
As a developer using Cucumber
|
5
|
-
I want to use the "the exit status should be" step
|
6
|
-
|
7
|
-
Scenario: exit status of 0
|
8
|
-
When I run `true`
|
9
|
-
Then the exit status should be 0
|
10
|
-
|
11
|
-
Scenario: non-zero exit status
|
12
|
-
When I run `false`
|
13
|
-
Then the exit status should be 1
|
14
|
-
And the exit status should not be 0
|
15
|
-
|
16
|
-
Scenario: Successfully run something
|
17
|
-
When I successfully run `true`
|
18
|
-
|
19
|
-
Scenario: Successfully run something for a long time
|
20
|
-
Given the default aruba timeout is 0 seconds
|
21
|
-
When I successfully run `sleep 1` for up to 2 seconds
|
22
|
-
|
23
|
-
Scenario: Unsuccessfully run something that takes too long
|
24
|
-
Given the default aruba timeout is 0 seconds
|
25
|
-
When I do aruba I successfully run `sleep 1`
|
26
|
-
Then aruba should fail with "process still alive after 0 seconds"
|
27
|
-
|
28
|
-
Scenario: Unsuccessfully run something
|
29
|
-
When I do aruba I successfully run `false`
|
30
|
-
Then aruba should fail with ""
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'aruba'
|
2
|
-
require 'aruba/processes/spawn_process'
|
3
|
-
require 'aruba/processes/in_process'
|
4
|
-
require 'shellwords'
|
5
|
-
require 'stringio'
|
6
|
-
|
7
|
-
class CustomMain
|
8
|
-
def initialize(argv, stdin, stdout, stderr, kernel)
|
9
|
-
@argv = argv
|
10
|
-
@stdin = stdin
|
11
|
-
@stdout = stdout
|
12
|
-
@stderr = stderr
|
13
|
-
@kernel = kernel
|
14
|
-
end
|
15
|
-
|
16
|
-
def execute!
|
17
|
-
@stdout.puts(@argv.map(&:reverse).join(' '))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
Before('@in-process') do
|
22
|
-
Aruba.process = Aruba::Processes::InProcess
|
23
|
-
Aruba.process.main_class = CustomMain
|
24
|
-
end
|
25
|
-
|
26
|
-
After('~@in-process') do
|
27
|
-
Aruba.process = Aruba::Processes::SpawnProcess
|
28
|
-
end
|
data/lib/aruba/matchers/mode.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# @!method have_permissions(permissions)
|
2
|
-
# This matchers checks if <file> has <perm> permissions
|
3
|
-
#
|
4
|
-
# @param [Fixnum, String] permissions
|
5
|
-
# The permissions as octal number, e.g. `0700`, or String, e.g. `'0700'`
|
6
|
-
#
|
7
|
-
# @return [TrueClass, FalseClass] The result
|
8
|
-
#
|
9
|
-
# false:
|
10
|
-
# * if file has permissions
|
11
|
-
# true:
|
12
|
-
# * if file does not have permissions
|
13
|
-
#
|
14
|
-
# @example Use matcher with octal number
|
15
|
-
#
|
16
|
-
# RSpec.describe do
|
17
|
-
# it { expect(file).to have_permissions(0700) }
|
18
|
-
# end
|
19
|
-
#
|
20
|
-
# @example Use matcher with string
|
21
|
-
#
|
22
|
-
# RSpec.describe do
|
23
|
-
# it { expect(file).to have_permissions('0700') }
|
24
|
-
# end
|
25
|
-
RSpec::Matchers.define :have_permissions do |expected|
|
26
|
-
expected_permissions = if expected.kind_of? Integer
|
27
|
-
expected.to_s(8)
|
28
|
-
else
|
29
|
-
expected.gsub(/^0*/, '')
|
30
|
-
end
|
31
|
-
|
32
|
-
match do |actual|
|
33
|
-
file_name = actual
|
34
|
-
actual_permissions = format( "%o", File::Stat.new(expand_path(file_name)).mode )[-4,4].gsub(/^0*/, '')
|
35
|
-
|
36
|
-
actual_permissions == expected_permissions
|
37
|
-
end
|
38
|
-
|
39
|
-
failure_message do |actual|
|
40
|
-
file_name = actual
|
41
|
-
actual_permissions = format( "%o", File::Stat.new(expand_path(file_name)).mode )[-4,4].gsub(/^0*/, '')
|
42
|
-
|
43
|
-
format("expected that file \"%s\" would have permissions \"%s\", but has \"%s\".", file_name, expected_permissions, actual_permissions)
|
44
|
-
end
|
45
|
-
|
46
|
-
failure_message_when_negated do |actual|
|
47
|
-
file_name = actual
|
48
|
-
actual_permissions = format( "%o", File::Stat.new(expand_path(file_name)).mode )[-4,4].gsub(/^0*/, '')
|
49
|
-
|
50
|
-
format("expected that file \"%s\" would not have permissions \"%s\", but has \"%s\".", file_name, expected_permissions, actual_permissions)
|
51
|
-
end
|
52
|
-
end
|
data/lib/aruba/utils.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module Aruba
|
2
|
-
module Utils
|
3
|
-
def detect_ruby(cmd)
|
4
|
-
if cmd =~ /^ruby\s/
|
5
|
-
cmd.gsub(/^ruby\s/, "#{current_ruby} ")
|
6
|
-
else
|
7
|
-
cmd
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def current_ruby
|
12
|
-
File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
13
|
-
end
|
14
|
-
|
15
|
-
def ensure_newline(str)
|
16
|
-
str.chomp << "\n"
|
17
|
-
end
|
18
|
-
|
19
|
-
module_function :detect_ruby, :current_ruby, :ensure_newline
|
20
|
-
end
|
21
|
-
end
|