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.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.nav +12 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +12 -0
  6. data/.simplecov +2 -0
  7. data/.travis.yml +5 -6
  8. data/Gemfile +53 -26
  9. data/History.md +17 -0
  10. data/LICENSE +1 -1
  11. data/README.md +45 -19
  12. data/Rakefile +12 -2
  13. data/TODO.md +3 -0
  14. data/aruba.gemspec +19 -8
  15. data/cucumber.yml +1 -1
  16. data/features/api/cd.feature +119 -0
  17. data/features/api/command/run.feature +37 -0
  18. data/features/api/command/which.feature +37 -0
  19. data/features/api/environment/append_environment_variable.feature +118 -0
  20. data/features/api/environment/prepend_environment_variable.feature +118 -0
  21. data/features/api/environment/set_environment_variable.feature +252 -0
  22. data/features/configuration/exit_timeout.feature +51 -0
  23. data/features/configuration/fixtures_directories.feature +31 -0
  24. data/features/configuration/fixtures_path_prefix.feature +24 -0
  25. data/features/configuration/io_timeout.feature +31 -0
  26. data/features/configuration/keep_ansi.feature +31 -0
  27. data/features/configuration/root_directory.feature +31 -0
  28. data/features/configuration/working_directory.feature +32 -0
  29. data/features/fixtures/cli-app/.gitignore +9 -0
  30. data/features/fixtures/cli-app/.rspec +2 -0
  31. data/features/fixtures/cli-app/README.md +34 -0
  32. data/features/fixtures/cli-app/Rakefile +1 -0
  33. data/features/fixtures/cli-app/bin/cli +6 -0
  34. data/features/fixtures/cli-app/cli-app.gemspec +26 -0
  35. data/features/fixtures/cli-app/features/support/env.rb +1 -0
  36. data/features/fixtures/cli-app/lib/cli/app.rb +13 -0
  37. data/features/fixtures/cli-app/lib/cli/app/version.rb +5 -0
  38. data/features/fixtures/cli-app/script/console +14 -0
  39. data/features/fixtures/cli-app/spec/cli/app_spec.rb +7 -0
  40. data/features/fixtures/cli-app/spec/spec_helper.rb +10 -0
  41. data/features/fixtures/copy/file.txt +1 -1
  42. data/features/hooks/after/command.feature +34 -0
  43. data/features/hooks/before/command.feature +61 -0
  44. data/features/matchers/directory/have_sub_directory.feature +110 -0
  45. data/features/matchers/file/be_existing_file.feature +82 -0
  46. data/features/matchers/file/have_file_content.feature +123 -0
  47. data/features/matchers/file/have_file_size.feature +107 -0
  48. data/features/matchers/path/be_an_absolute_path.feature +74 -0
  49. data/features/matchers/path/be_an_existing_path.feature +97 -0
  50. data/features/matchers/path/have_permissions.feature +118 -0
  51. data/features/matchers/timeouts.feature +48 -0
  52. data/features/step_definitions/aruba_dev_steps.rb +69 -1
  53. data/features/steps/commands/exit_statuses.feature +136 -0
  54. data/features/steps/commands/in_process.feature +129 -0
  55. data/features/steps/commands/run.feature +36 -0
  56. data/features/steps/environment/home_variable.feature +49 -0
  57. data/features/steps/environment/set_environment_variable.feature +34 -0
  58. data/features/support/aruba.rb +5 -0
  59. data/features/support/env.rb +8 -4
  60. data/lib/aruba.rb +20 -8
  61. data/lib/aruba/announcer.rb +1 -0
  62. data/lib/aruba/api.rb +18 -1179
  63. data/lib/aruba/api/command.rb +351 -0
  64. data/lib/aruba/api/core.rb +141 -0
  65. data/lib/aruba/api/deprecated.rb +549 -0
  66. data/lib/aruba/api/environment.rb +61 -0
  67. data/lib/aruba/api/filesystem.rb +305 -0
  68. data/lib/aruba/api/rvm.rb +39 -0
  69. data/lib/aruba/aruba_path.rb +75 -0
  70. data/lib/aruba/basic_configuration.rb +208 -0
  71. data/lib/aruba/basic_configuration/option.rb +25 -0
  72. data/lib/aruba/config.rb +43 -30
  73. data/lib/aruba/config/jruby.rb +14 -0
  74. data/lib/aruba/config_wrapper.rb +17 -0
  75. data/lib/aruba/contracts/relative_path.rb +13 -0
  76. data/lib/aruba/creators/aruba_file_creator.rb +32 -0
  77. data/lib/aruba/creators/aruba_fixed_size_file_creator.rb +32 -0
  78. data/lib/aruba/cucumber.rb +87 -53
  79. data/lib/aruba/cucumber/hooks.rb +65 -10
  80. data/lib/aruba/environment.rb +121 -0
  81. data/lib/aruba/errors.rb +3 -0
  82. data/lib/aruba/extensions/string/strip.rb +24 -0
  83. data/lib/aruba/hooks.rb +54 -0
  84. data/lib/aruba/jruby.rb +4 -9
  85. data/lib/aruba/matchers/command.rb +1 -79
  86. data/lib/aruba/matchers/command/be_successfully_executed.rb +30 -0
  87. data/lib/aruba/matchers/command/have_exit_status.rb +47 -0
  88. data/lib/aruba/matchers/command/have_finished_in_time.rb +42 -0
  89. data/lib/aruba/matchers/directory.rb +1 -59
  90. data/lib/aruba/matchers/directory/be_an_existing_directory.rb +34 -0
  91. data/lib/aruba/matchers/directory/have_sub_directory.rb +49 -0
  92. data/lib/aruba/matchers/file.rb +1 -177
  93. data/lib/aruba/matchers/file/be_an_existing_file.rb +34 -0
  94. data/lib/aruba/matchers/file/have_file_content.rb +58 -0
  95. data/lib/aruba/matchers/file/have_file_size.rb +43 -0
  96. data/lib/aruba/matchers/file/have_same_file_content.rb +44 -0
  97. data/lib/aruba/matchers/path.rb +1 -99
  98. data/lib/aruba/matchers/path/a_path_matching_pattern.rb +21 -0
  99. data/lib/aruba/matchers/path/be_an_absolute_path.rb +32 -0
  100. data/lib/aruba/matchers/path/be_an_existing_path.rb +33 -0
  101. data/lib/aruba/matchers/path/have_permissions.rb +60 -0
  102. data/lib/aruba/matchers/path/match_path_pattern.rb +41 -0
  103. data/lib/aruba/matchers/rspec.rb +0 -0
  104. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
  105. data/lib/aruba/platform.rb +230 -0
  106. data/lib/aruba/process_monitor.rb +23 -5
  107. data/lib/aruba/processes/basic_process.rb +35 -1
  108. data/lib/aruba/processes/debug_process.rb +26 -15
  109. data/lib/aruba/processes/in_process.rb +21 -9
  110. data/lib/aruba/processes/spawn_process.rb +29 -19
  111. data/lib/aruba/reporting.rb +2 -0
  112. data/lib/aruba/rspec.rb +61 -13
  113. data/lib/aruba/runtime.rb +33 -0
  114. data/script/bootstrap +4 -6
  115. data/spec/aruba/api/runtime_spec.rb +28 -0
  116. data/spec/aruba/api_spec.rb +129 -126
  117. data/spec/aruba/aruba_path_spec.rb +65 -0
  118. data/spec/aruba/basic_configuration_spec.rb +5 -0
  119. data/spec/aruba/config_wrapper_spec.rb +25 -0
  120. data/spec/aruba/configuration_spec.rb +5 -0
  121. data/spec/aruba/jruby_spec.rb +34 -18
  122. data/spec/aruba/matchers/directory_spec.rb +6 -7
  123. data/spec/aruba/matchers/file_spec.rb +16 -20
  124. data/spec/aruba/matchers/path_spec.rb +14 -11
  125. data/spec/aruba/rspec_spec.rb +15 -0
  126. data/spec/aruba/runtime_spec.rb +29 -0
  127. data/spec/aruba/spawn_process_spec.rb +2 -2
  128. data/spec/spec_helper.rb +10 -2
  129. data/spec/support/configs/rspec.rb +1 -1
  130. data/spec/support/matchers/option.rb +35 -0
  131. data/spec/support/shared_contexts/aruba.rb +10 -8
  132. data/spec/support/shared_examples/configuration.rb +116 -0
  133. metadata +182 -33
  134. data/.rvmrc +0 -1
  135. data/features/before_cmd_hooks.feature +0 -61
  136. data/features/command_environment_variables.feature +0 -31
  137. data/features/custom_ruby_process.feature +0 -12
  138. data/features/exit_statuses.feature +0 -30
  139. data/features/support/custom_main.rb +0 -28
  140. data/lib/aruba/matchers/mode.rb +0 -52
  141. 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
@@ -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
@@ -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