aruba 0.11.0.pre → 0.11.0.pre2

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.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/History.md +21 -1
  4. data/aruba.gemspec +1 -0
  5. data/features/api/command/find_command.feature +83 -0
  6. data/features/api/command/last_command_started.feature +50 -0
  7. data/features/api/command/last_command_stopped.feature +89 -0
  8. data/features/api/command/run.feature +259 -0
  9. data/features/api/command/stop.feature +53 -1
  10. data/features/api/text/replace_variables.feature +1 -1
  11. data/features/getting_started/run_commands.feature +177 -0
  12. data/features/matchers/file/be_existing_executable.feature +87 -0
  13. data/features/{integration/rspec/getting_started.feature → rspec/integration.feature} +31 -0
  14. data/fixtures/getting-started-app/Gemfile +1 -1
  15. data/lib/aruba.rb +0 -19
  16. data/lib/aruba/api.rb +2 -0
  17. data/lib/aruba/api/command.rb +103 -44
  18. data/lib/aruba/api/core.rb +13 -8
  19. data/lib/aruba/api/deprecated.rb +26 -4
  20. data/lib/aruba/api/environment.rb +21 -13
  21. data/lib/aruba/api/filesystem.rb +13 -0
  22. data/lib/aruba/api/rvm.rb +5 -0
  23. data/lib/aruba/api/text.rb +7 -1
  24. data/lib/aruba/aruba_path.rb +6 -0
  25. data/lib/aruba/basic_configuration.rb +35 -3
  26. data/lib/aruba/basic_configuration/option.rb +7 -0
  27. data/lib/aruba/cli.rb +4 -0
  28. data/lib/aruba/command.rb +47 -1
  29. data/lib/aruba/config.rb +15 -2
  30. data/lib/aruba/config_wrapper.rb +49 -8
  31. data/lib/aruba/console.rb +4 -1
  32. data/lib/aruba/console/help.rb +2 -0
  33. data/lib/aruba/contracts/absolute_path.rb +7 -0
  34. data/lib/aruba/contracts/enum.rb +5 -0
  35. data/lib/aruba/contracts/is_power_of_two.rb +9 -2
  36. data/lib/aruba/contracts/relative_path.rb +7 -0
  37. data/lib/aruba/cucumber/command.rb +6 -9
  38. data/lib/aruba/cucumber/file.rb +1 -1
  39. data/lib/aruba/cucumber/hooks.rb +36 -29
  40. data/lib/aruba/errors.rb +16 -1
  41. data/lib/aruba/events.rb +39 -0
  42. data/lib/aruba/extensions/string/strip.rb +1 -0
  43. data/lib/aruba/file_size.rb +11 -0
  44. data/lib/aruba/hooks.rb +2 -0
  45. data/lib/aruba/in_config_wrapper.rb +24 -0
  46. data/lib/aruba/in_process.rb +2 -0
  47. data/lib/aruba/initializer.rb +37 -0
  48. data/lib/aruba/matchers/base/base_matcher.rb +2 -0
  49. data/lib/aruba/matchers/base/object_formatter.rb +4 -0
  50. data/lib/aruba/matchers/collection/all.rb +2 -0
  51. data/lib/aruba/matchers/collection/include_an_object.rb +2 -0
  52. data/lib/aruba/matchers/command/have_exit_status.rb +1 -1
  53. data/lib/aruba/matchers/command/have_finished_in_time.rb +1 -10
  54. data/lib/aruba/matchers/command/have_output.rb +1 -10
  55. data/lib/aruba/matchers/command/have_output_on_stderr.rb +1 -10
  56. data/lib/aruba/matchers/command/have_output_on_stdout.rb +1 -10
  57. data/lib/aruba/matchers/file/be_an_existing_executable.rb +37 -0
  58. data/lib/aruba/platform.rb +4 -0
  59. data/lib/aruba/platforms/announcer.rb +225 -0
  60. data/lib/aruba/platforms/aruba_file_creator.rb +4 -0
  61. data/lib/aruba/platforms/aruba_fixed_size_file_creator.rb +4 -0
  62. data/lib/aruba/{aruba_logger.rb → platforms/aruba_logger.rb} +4 -0
  63. data/lib/aruba/platforms/command_monitor.rb +229 -0
  64. data/lib/aruba/platforms/determine_disk_usage.rb +5 -0
  65. data/lib/aruba/platforms/determine_file_size.rb +9 -0
  66. data/lib/aruba/platforms/disk_usage_calculator.rb +9 -0
  67. data/lib/aruba/platforms/local_environment.rb +12 -0
  68. data/lib/aruba/platforms/simple_table.rb +11 -0
  69. data/lib/aruba/platforms/unix_command_string.rb +3 -0
  70. data/lib/aruba/platforms/unix_environment_variables.rb +3 -0
  71. data/lib/aruba/platforms/unix_platform.rb +20 -2
  72. data/lib/aruba/platforms/unix_which.rb +6 -2
  73. data/lib/aruba/platforms/windows_command_string.rb +7 -0
  74. data/lib/aruba/platforms/windows_environment_variables.rb +2 -0
  75. data/lib/aruba/platforms/windows_platform.rb +3 -0
  76. data/lib/aruba/platforms/windows_which.rb +6 -2
  77. data/lib/aruba/processes/basic_process.rb +20 -5
  78. data/lib/aruba/processes/debug_process.rb +3 -1
  79. data/lib/aruba/processes/in_process.rb +18 -2
  80. data/lib/aruba/processes/spawn_process.rb +14 -13
  81. data/lib/aruba/rspec.rb +34 -23
  82. data/lib/aruba/runtime.rb +65 -6
  83. data/lib/aruba/setup.rb +87 -0
  84. data/lib/aruba/version.rb +1 -1
  85. data/spec/aruba/api_spec.rb +13 -36
  86. data/spec/aruba/{config_wrapper_spec.rb → in_config_wrapper_spec.rb} +1 -1
  87. data/spec/aruba/spawn_process_spec.rb +9 -14
  88. data/spec/support/configs/pry.rb +3 -0
  89. data/spec/support/shared_contexts/aruba.rb +1 -0
  90. metadata +40 -14
  91. data/features/getting_started/supported_programming_languages.feature +0 -89
  92. data/lib/aruba/announcer.rb +0 -219
  93. data/lib/aruba/matchers/rspec.rb +0 -0
  94. data/lib/aruba/process_monitor.rb +0 -201
  95. data/lib/aruba/processes/null_process.rb +0 -26
data/lib/aruba/config.rb CHANGED
@@ -2,7 +2,7 @@ require 'contracts'
2
2
 
3
3
  require 'aruba/version'
4
4
  require 'aruba/basic_configuration'
5
- require 'aruba/config_wrapper'
5
+ require 'aruba/in_config_wrapper'
6
6
  require 'aruba/hooks'
7
7
 
8
8
  require 'aruba/contracts/relative_path'
@@ -11,8 +11,11 @@ require 'aruba/contracts/enum'
11
11
 
12
12
  require 'aruba/contracts/is_power_of_two'
13
13
 
14
+ # Aruba
14
15
  module Aruba
15
16
  # Aruba Configuration
17
+ #
18
+ # This defines the configuration options of aruba
16
19
  class Configuration < BasicConfiguration
17
20
  if Aruba::VERSION >= '1.0.0'
18
21
  option_reader :root_directory, :contract => { None => String }, :default => Dir.getwd
@@ -64,13 +67,21 @@ module Aruba
64
67
  end
65
68
  end
66
69
 
67
- # Main Module
70
+ # Aruba
68
71
  module Aruba
69
72
  @config = Configuration.new
70
73
 
71
74
  class << self
72
75
  attr_reader :config
73
76
 
77
+ # Configure aruba
78
+ #
79
+ # @example How to configure aruba
80
+ #
81
+ # Aruba.configure do |config|
82
+ # config.<option> = <value>
83
+ # end
84
+ #
74
85
  def configure(&block)
75
86
  @config.configure(&block)
76
87
 
@@ -79,10 +90,12 @@ module Aruba
79
90
  end
80
91
  end
81
92
 
93
+ # Aruba
82
94
  module Aruba
83
95
  # Old Config
84
96
  #
85
97
  # @private
98
+ # @deprecated
86
99
  class Config < Configuration
87
100
  def initialize(*args)
88
101
  warn('The use of "Aruba::Config" is deprecated. Use "Aruba::Configuration" instead.')
@@ -1,17 +1,58 @@
1
1
  module Aruba
2
+ # This wraps the current runtime configuration of aruba.
3
+ # If an option is changed, it notifies the event queue.
4
+ #
5
+ # This class is not meant for direct use - ConfigWrapper.new - by normal
6
+ # users.
7
+ #
8
+ # @private
2
9
  class ConfigWrapper
3
- attr_reader :config
4
- private :config
10
+ private
5
11
 
6
- def initialize(config)
7
- @config = config.dup
12
+ attr_reader :config, :event_bus
13
+
14
+ public
15
+
16
+ # Create proxy
17
+ #
18
+ # @param [Config] config
19
+ # An aruba config object.
20
+ #
21
+ # @param [#notify] event_bus
22
+ # The event queue which should be notified.
23
+ def initialize(config, event_bus)
24
+ @config = config
25
+ @event_bus = event_bus
26
+ end
27
+
28
+ # Proxy all methods
29
+ #
30
+ # If one method ends with "=", e.g. ":option1=", then notify the event
31
+ # queue, that the user changes the value of "option1"
32
+ def method_missing(name, *args, &block)
33
+ event_bus.notify Events::ChangedConfiguration.new(:changed => { :name => name.to_s.gsub(/=$/, ''), :value => args.first }) if name.to_s.end_with? '='
34
+
35
+ config.send(name, *args, &block)
36
+ end
37
+
38
+ # Pass on respond_to?-calls
39
+ def respond_to_missing?(name, _include_private)
40
+ config.respond_to? name
8
41
  end
9
42
 
10
- def method_missing(name, *args)
11
- fail ArgumentError, 'Options take no argument' if args.count > 0
12
- fail UnknownOptionError, %(Option "#{name}" is unknown. Please use only earlier defined options) unless config.key? name
43
+ # Compare two configs
44
+ #
45
+ # The comparism is done based on their values. No hooks are compared.
46
+ #
47
+ # Somehow `#respond_to_missing?`, `method_missing?` and `respond_to?` don't
48
+ # help here.
49
+ def ==(other)
50
+ config == other
51
+ end
13
52
 
14
- config[name]
53
+ # Pass on respond_to?-calls
54
+ def respond_to?(m)
55
+ config.respond_to? m
15
56
  end
16
57
  end
17
58
  end
data/lib/aruba/console.rb CHANGED
@@ -3,8 +3,12 @@ require 'irb'
3
3
  require 'aruba/api'
4
4
  require 'aruba/console/help'
5
5
 
6
+ # Aruba
6
7
  module Aruba
8
+ # Consule
7
9
  class Console
10
+ # Start the aruba console
11
+ #
8
12
  # rubocop:disable Metrics/MethodLength
9
13
  def start
10
14
  # Start IRB with current context:
@@ -17,7 +21,6 @@ module Aruba
17
21
  IRB.conf[:PROMPT] = {}
18
22
  IRB.conf[:PROMPT][:ARUBA] = {
19
23
  :PROMPT_I => '%N:%03n:%i> ',
20
- :PROMPT_N => '%N:%03n:%i> ',
21
24
  :PROMPT_S => '%N:%03n:%i%l ',
22
25
  :PROMPT_C => '%N:%03n:%i* ',
23
26
  :RETURN => "# => %s\n"
@@ -1,6 +1,8 @@
1
1
  require 'aruba/api'
2
2
 
3
+ # Aruba
3
4
  module Aruba
5
+ # Consule
4
6
  class Console
5
7
  # Helpers for Aruba::Console
6
8
  module Help
@@ -1,8 +1,15 @@
1
1
  require 'aruba/aruba_path'
2
2
 
3
+ # Aruba
3
4
  module Aruba
5
+ # Contracts
4
6
  module Contracts
7
+ # Check if path is absolute
5
8
  class AbsolutePath
9
+ # Check
10
+ #
11
+ # @param [Object] value
12
+ # The value to be checked
6
13
  def self.valid?(value)
7
14
  ArubaPath.new(value).absolute?
8
15
  rescue
@@ -1,7 +1,10 @@
1
1
  require 'contracts'
2
2
 
3
+ # Aruba
3
4
  module Aruba
5
+ # Contracts
4
6
  module Contracts
7
+ # Enum
5
8
  class Enum < ::Contracts::CallableClass
6
9
  private
7
10
 
@@ -9,10 +12,12 @@ module Aruba
9
12
 
10
13
  public
11
14
 
15
+ # Create contract
12
16
  def initialize(*vals)
13
17
  @vals = vals
14
18
  end
15
19
 
20
+ # Check if value is part of array
16
21
  def valid?(val)
17
22
  vals.include? val
18
23
  end
@@ -1,12 +1,19 @@
1
1
  require 'aruba/aruba_path'
2
2
 
3
+ # Aruba
3
4
  module Aruba
5
+ # Contracts
4
6
  module Contracts
7
+ # Is value power of two
5
8
  class IsPowerOfTwo
6
- def self.valid?(x)
9
+ # Check value
10
+ #
11
+ # @param [Integer] value
12
+ # The value to be checked
13
+ def self.valid?(value)
7
14
  # explanation for algorithm can be found here:
8
15
  # http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/
9
- x != 0 && (x & (x - 1)) == 0 ? true : false
16
+ value != 0 && (value & (value - 1)) == 0 ? true : false
10
17
  rescue
11
18
  false
12
19
  end
@@ -1,8 +1,15 @@
1
1
  require 'aruba/aruba_path'
2
2
 
3
+ # Aruba
3
4
  module Aruba
5
+ # Contracts
4
6
  module Contracts
7
+ # Is value relative path
5
8
  class RelativePath
9
+ # Check
10
+ #
11
+ # @param [String] value
12
+ # The path to be checked
6
13
  def self.valid?(value)
7
14
  ArubaPath.new(value).relative?
8
15
  rescue
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  When(/^I run `([^`]*)`$/)do |cmd|
13
13
  cmd = sanitize_text(cmd)
14
- run_simple(cmd, false)
14
+ run_simple(cmd, fail_on_error: false)
15
15
  end
16
16
 
17
17
  When(/^I successfully run "(.*)"$/)do |cmd|
@@ -25,7 +25,7 @@ end
25
25
  ## I successfully run `sleep 29` for up to 30 seconds
26
26
  When(/^I successfully run `(.*?)`(?: for up to (\d+) seconds)?$/)do |cmd, secs|
27
27
  cmd = sanitize_text(cmd)
28
- run_simple(cmd, true, secs && secs.to_i)
28
+ run_simple(cmd, fail_on_error: true, exit_timeout: secs && secs.to_i)
29
29
  end
30
30
 
31
31
  When(/^I run "([^"]*)" interactively$/) do |cmd|
@@ -107,9 +107,6 @@ When(/^I stop the command(?: started last)? if (output|stdout|stderr) contains:$
107
107
  end
108
108
  rescue ChildProcess::TimeoutError, TimeoutError
109
109
  last_command_started.terminate
110
- ensure
111
- announcer.announce :stdout, last_command_started.stdout
112
- announcer.announce :stderr, last_command_started.stderr
113
110
  end
114
111
  end
115
112
 
@@ -158,7 +155,7 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
158
155
  end
159
156
 
160
157
  commands = if cmd
161
- [process_monitor.get_process(Aruba.platform.detect_ruby(cmd))]
158
+ [aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
162
159
  else
163
160
  all_commands
164
161
  end
@@ -171,7 +168,7 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
171
168
 
172
169
  if Aruba::VERSION < '1.0'
173
170
  combined_output = commands.map do |c|
174
- c.stop(announcer)
171
+ c.stop
175
172
  c.send(channel.to_sym).chomp
176
173
  end.join("\n")
177
174
 
@@ -206,7 +203,7 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
206
203
  end
207
204
 
208
205
  commands = if cmd
209
- [process_monitor.get_process(Aruba.platform.detect_ruby(cmd))]
206
+ [aruba.command_monitor.find(Aruba.platform.detect_ruby(cmd))]
210
207
  else
211
208
  all_commands
212
209
  end
@@ -219,7 +216,7 @@ Then(/^(?:the )?(output|stderr|stdout)(?: from "([^"]*)")? should( not)? contain
219
216
 
220
217
  if Aruba::VERSION < '1.0'
221
218
  combined_output = commands.map do |c|
222
- c.stop(announcer)
219
+ c.stop
223
220
  c.send(channel.to_sym).chomp
224
221
  end.join("\n")
225
222
 
@@ -88,7 +88,7 @@ Then(/^the following files should (not )?exist:$/) do |negated, files|
88
88
  end
89
89
  end
90
90
 
91
- Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist$/) do |file, expect_match|
91
+ Then(/^(?:a|the) file(?: named)? "([^"]*)" should (not )?exist(?: anymore)?$/) do |file, expect_match|
92
92
  if expect_match
93
93
  expect(file).not_to be_an_existing_file
94
94
  else
@@ -21,7 +21,7 @@ end
21
21
  After do
22
22
  restore_env
23
23
  terminate_all_commands
24
- process_monitor.clear
24
+ aruba.command_monitor.clear
25
25
  end
26
26
 
27
27
  Before('~@no-clobber') do
@@ -29,85 +29,92 @@ Before('~@no-clobber') do
29
29
  end
30
30
 
31
31
  Before('@puts') do
32
- announcer.mode = :puts
32
+ aruba.announcer.mode = :puts
33
33
  end
34
34
 
35
35
  Before('@announce-command') do
36
- announcer.activate :command
36
+ aruba.announcer.activate :command
37
37
  end
38
38
 
39
39
  Before('@announce-cmd') do
40
40
  Aruba.platform.deprecated 'The use of "@announce-cmd"-hook is deprecated. Please use "@announce-command"'
41
41
 
42
- announcer.activate :command
42
+ aruba.announcer.activate :command
43
43
  end
44
44
 
45
45
  Before('@announce-output') do
46
- announcer.activate :stdout
47
- announcer.activate :stderr
46
+ aruba.announcer.activate :stdout
47
+ aruba.announcer.activate :stderr
48
48
  end
49
49
 
50
50
  Before('@announce-stdout') do
51
- announcer.activate :stdout
51
+ aruba.announcer.activate :stdout
52
52
  end
53
53
 
54
54
  Before('@announce-stderr') do
55
- announcer.activate :stderr
55
+ aruba.announcer.activate :stderr
56
56
  end
57
57
 
58
58
  Before('@announce-dir') do
59
59
  Aruba.platform.deprecated 'The use of "@announce-dir"-hook is deprecated. Please use "@announce-directory"'
60
60
 
61
- announcer.activate :directory
61
+ aruba.announcer.activate :directory
62
62
  end
63
63
 
64
64
  Before('@announce-directory') do
65
- announcer.activate :directory
65
+ aruba.announcer.activate :directory
66
66
  end
67
67
 
68
68
  Before('@announce-stop-signal') do
69
- announcer.activate :stop_signal
69
+ aruba.announcer.activate :stop_signal
70
70
  end
71
71
 
72
72
  Before('@announce-env') do
73
- Aruba.platform.deprecated 'The use of "@announce-env"-hook is deprecated. Please use "@announce-modified-environment"'
73
+ Aruba.platform.deprecated 'The use of "@announce-env"-hook is deprecated. Please use "@announce-changed-environment"'
74
74
 
75
- announcer.activate :environment
75
+ aruba.announcer.activate :environment
76
76
  end
77
77
 
78
78
  Before('@announce-environment') do
79
- Aruba.platform.deprecated '@announce-environment is deprecated. Use @announce-modified-environment instead'
79
+ Aruba.platform.deprecated '@announce-environment is deprecated. Use @announce-changed-environment instead'
80
80
 
81
- announcer.activate :modified_environment
81
+ aruba.announcer.activate :changed_environment
82
82
  end
83
83
 
84
84
  Before('@announce-full-environment') do
85
- announcer.activate :full_environment
85
+ aruba.announcer.activate :full_environment
86
86
  end
87
87
 
88
88
  Before('@announce-modified-environment') do
89
- announcer.activate :modified_environment
89
+ Aruba.platform.deprecated '@announce-modified-environment is deprecated. Use @announce-changed-environment instead'
90
+
91
+ aruba.announcer.activate :changed_environment
92
+ end
93
+
94
+ Before('@announce-changed-environment') do
95
+ aruba.announcer.activate :changed_environment
90
96
  end
91
97
 
92
98
  Before('@announce-timeout') do
93
- announcer.activate :timeout
99
+ aruba.announcer.activate :timeout
94
100
  end
95
101
 
96
102
  Before('@announce-wait-time') do
97
- announcer.activate :wait_time
103
+ aruba.announcer.activate :wait_time
98
104
  end
99
105
 
100
106
  Before('@announce') do
101
- announcer.activate :command
102
- announcer.activate :stdout
103
- announcer.activate :stderr
104
- announcer.activate :directory
105
- announcer.activate :modified_environment
106
- announcer.activate :full_environment
107
- announcer.activate :environment
108
- announcer.activate :timeout
109
- announcer.activate :wait_time
110
- announcer.activate :stop_signal
107
+ aruba.announcer.activate :changed_environment
108
+ aruba.announcer.activate :command
109
+ aruba.announcer.activate :directory
110
+ aruba.announcer.activate :environment
111
+ aruba.announcer.activate :full_environment
112
+ aruba.announcer.activate :modified_environment
113
+ aruba.announcer.activate :stderr
114
+ aruba.announcer.activate :stdout
115
+ aruba.announcer.activate :stop_signal
116
+ aruba.announcer.activate :timeout
117
+ aruba.announcer.activate :wait_time
111
118
  end
112
119
 
113
120
  Before('@debug') do
data/lib/aruba/errors.rb CHANGED
@@ -11,6 +11,21 @@ module Aruba
11
11
  # Raised if one tries to use an unknown configuration option
12
12
  class UnknownOptionError < ArgumentError; end
13
13
 
14
- # Rais if command already died
14
+ # Raised if command already died
15
15
  class CommandAlreadyStoppedError < Error; end
16
+
17
+ # Raised if one tries to access last command started, but no command
18
+ # has been started
19
+ class NoCommandHasBeenStartedError < Error; end
20
+
21
+ # Raised if one tries to access last command stopped, but no command
22
+ # has been stopped
23
+ class NoCommandHasBeenStoppedError < Error; end
24
+
25
+ # Raised if one looked for a command, but no matching was found
26
+ class CommandNotFoundError < ArgumentError; end
27
+
28
+ # Raised if command was already started, otherwise aruba forgets about the
29
+ # previous pid and you've got hidden commands run
30
+ class CommandAlreadyStartedError < Error; end
16
31
  end