aruba 0.8.1 → 0.9.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +3 -1
  4. data/Gemfile +13 -10
  5. data/History.md +25 -7
  6. data/README.md +6 -1
  7. data/Rakefile +16 -3
  8. data/aruba.gemspec +10 -2
  9. data/bin/aruba +7 -0
  10. data/cucumber.yml +11 -2
  11. data/features/api/command/extract_text.feature +97 -0
  12. data/features/api/command/unescape_text.feature +119 -0
  13. data/features/api/core/expand_path.feature +16 -0
  14. data/features/api/{cd.feature → filesystem/cd.feature} +2 -1
  15. data/features/api/filesystem/create_directory.feature +57 -0
  16. data/features/api/filesystem/disk_usage.feature +151 -0
  17. data/features/api/filesystem/does_exist.feature +62 -0
  18. data/features/api/filesystem/is_absolute.feature +48 -0
  19. data/features/api/filesystem/is_directory.feature +53 -0
  20. data/features/api/filesystem/is_file.feature +54 -0
  21. data/features/api/filesystem/is_relative.feature +48 -0
  22. data/features/cli/console.feature +52 -0
  23. data/features/configuration/console_history_file.feature +38 -0
  24. data/features/configuration/exit_timeout.feature +2 -1
  25. data/features/configuration/fixtures_path_prefix.feature +0 -1
  26. data/features/configuration/home_directory.feature +0 -1
  27. data/features/configuration/io_timeout.feature +0 -1
  28. data/features/configuration/keep_ansi.feature +1 -2
  29. data/features/configuration/log_level.feature +38 -0
  30. data/features/configuration/physical_block_size.feature +53 -0
  31. data/features/configuration/remove_ansi_escape_sequences.feature +38 -0
  32. data/features/configuration/root_directory.feature +0 -1
  33. data/features/configuration/working_directory.feature +2 -1
  34. data/features/fixtures/cli-app/README.md +5 -0
  35. data/features/fixtures/cli-app/lib/cli/app.rb +1 -1
  36. data/features/fixtures/cli-app/spec/spec_helper.rb +1 -2
  37. data/features/fixtures/cli-app/spec/support/aruba.rb +1 -0
  38. data/features/fixtures/empty-app/lib/cli/app.rb +1 -1
  39. data/features/fixtures/empty-app/spec/spec_helper.rb +1 -1
  40. data/features/step_definitions/aruba_dev_steps.rb +12 -1
  41. data/features/support/env.rb +1 -1
  42. data/lib/aruba/announcer.rb +1 -14
  43. data/lib/aruba/api.rb +6 -6
  44. data/lib/aruba/api/command.rb +74 -12
  45. data/lib/aruba/api/core.rb +18 -11
  46. data/lib/aruba/api/deprecated.rb +60 -72
  47. data/lib/aruba/api/filesystem.rb +41 -16
  48. data/lib/aruba/aruba_logger.rb +77 -0
  49. data/lib/aruba/aruba_path.rb +33 -0
  50. data/lib/aruba/basic_configuration.rb +2 -2
  51. data/lib/aruba/cli.rb +11 -0
  52. data/lib/aruba/config.rb +13 -3
  53. data/lib/aruba/config/jruby.rb +5 -2
  54. data/lib/aruba/console.rb +66 -0
  55. data/lib/aruba/console/help.rb +33 -0
  56. data/lib/aruba/contracts/is_power_of_two.rb +15 -0
  57. data/lib/aruba/cucumber.rb +27 -10
  58. data/lib/aruba/cucumber/hooks.rb +15 -8
  59. data/lib/aruba/disk_usage_calculator.rb +7 -0
  60. data/lib/aruba/file_size.rb +52 -0
  61. data/lib/aruba/in_process.rb +1 -1
  62. data/lib/aruba/jruby.rb +1 -1
  63. data/lib/aruba/matchers/command.rb +1 -1
  64. data/lib/aruba/matchers/directory.rb +1 -1
  65. data/lib/aruba/matchers/environment.rb +1 -1
  66. data/lib/aruba/matchers/file.rb +1 -1
  67. data/lib/aruba/matchers/path.rb +1 -1
  68. data/lib/aruba/matchers/path/match_path_pattern.rb +1 -1
  69. data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
  70. data/lib/aruba/platform.rb +14 -242
  71. data/lib/aruba/{creators → platforms}/aruba_file_creator.rb +3 -3
  72. data/lib/aruba/{creators → platforms}/aruba_fixed_size_file_creator.rb +2 -2
  73. data/lib/aruba/platforms/simple_table.rb +36 -0
  74. data/lib/aruba/platforms/unix_command_string.rb +24 -0
  75. data/lib/aruba/platforms/unix_environment_variables.rb +130 -0
  76. data/lib/aruba/platforms/unix_platform.rb +226 -0
  77. data/lib/aruba/platforms/unix_which.rb +83 -0
  78. data/lib/aruba/platforms/windows_command_string.rb +23 -0
  79. data/lib/aruba/platforms/windows_environment_variables.rb +83 -0
  80. data/lib/aruba/platforms/windows_platform.rb +39 -0
  81. data/lib/aruba/platforms/windows_which.rb +104 -0
  82. data/lib/aruba/process_monitor.rb +3 -3
  83. data/lib/aruba/processes/basic_process.rb +23 -3
  84. data/lib/aruba/processes/debug_process.rb +2 -2
  85. data/lib/aruba/processes/in_process.rb +1 -1
  86. data/lib/aruba/processes/spawn_process.rb +10 -4
  87. data/lib/aruba/reporting.rb +1 -1
  88. data/lib/aruba/rspec.rb +8 -6
  89. data/lib/aruba/runtime.rb +8 -5
  90. data/lib/aruba/version.rb +1 -1
  91. data/spec/aruba/api_spec.rb +25 -23
  92. data/spec/aruba/aruba_path_spec.rb +37 -0
  93. data/spec/aruba/jruby_spec.rb +1 -1
  94. data/spec/aruba/matchers/file_spec.rb +2 -2
  95. data/spec/aruba/matchers/path_spec.rb +3 -3
  96. data/spec/aruba/platform/simple_table_spec.rb +23 -0
  97. data/spec/aruba/platform/windows_environment_variables_spec.rb +500 -0
  98. data/spec/aruba/spawn_process_spec.rb +3 -1
  99. metadata +90 -12
  100. data/lib/aruba/contracts/is_a.rb +0 -21
  101. data/lib/aruba/environment.rb +0 -121
@@ -0,0 +1,48 @@
1
+ Feature: Check if path is relative
2
+
3
+ Use the `#relative?`-method to check if a path is an relative path.
4
+
5
+ ```ruby
6
+ require 'spec_helper'
7
+
8
+ RSpec.configure do |config|
9
+ config.include Aruba::Api
10
+ end
11
+
12
+ RSpec.describe 'Check if directory or file is relative' do
13
+ let(:path) { '/path/to/file.txt' }
14
+
15
+ it { expect(relative?(path)).to be true }
16
+ end
17
+ ```
18
+
19
+ Background:
20
+ Given I use a fixture named "cli-app"
21
+
22
+ Scenario: Is path relative
23
+ Given a file named "spec/create_directory_spec.rb" with:
24
+ """
25
+ require 'spec_helper'
26
+
27
+ RSpec.describe 'Check if directory or file is relative', :type => :aruba do
28
+ let(:path) { 'file.txt' }
29
+
30
+ it { expect(relative?(path)).to be true }
31
+ end
32
+ """
33
+ When I run `rspec`
34
+ Then the specs should all pass
35
+
36
+ Scenario: Path should be relative, but it's relative
37
+ Given a file named "spec/create_directory_spec.rb" with:
38
+ """
39
+ require 'spec_helper'
40
+
41
+ RSpec.describe 'Check if directory or file is relative', :type => :aruba do
42
+ let(:path) { '/path/to/file.txt' }
43
+
44
+ it { expect(relative?(path)).to be false }
45
+ end
46
+ """
47
+ When I run `rspec`
48
+ Then the specs should all pass
@@ -0,0 +1,52 @@
1
+ Feature: Aruba Console
2
+
3
+ Background:
4
+ Given a mocked home directory
5
+
6
+ Scenario: Start console
7
+ Given I run `aruba console` interactively
8
+ When I close the stdin stream
9
+ Then the output should contain:
10
+ """
11
+ aruba:001:0>
12
+ """
13
+
14
+ @ignore-platform-java
15
+ Scenario: Show help
16
+ Given I run `aruba console` interactively
17
+ And I type "aruba_help"
18
+ When I close the stdin stream
19
+ Then the output should contain:
20
+ """
21
+ Version:
22
+ """
23
+ And the output should contain:
24
+ """
25
+ Issue Tracker:
26
+ """
27
+ And the output should contain:
28
+ """
29
+ Documentation:
30
+ """
31
+
32
+ @ignore-platform-java
33
+ Scenario: Show methods
34
+ Given I run `aruba console` interactively
35
+ And I type "aruba_methods"
36
+ When I close the stdin stream
37
+ Then the output should contain:
38
+ """
39
+ Methods:
40
+ """
41
+ And the output should contain:
42
+ """
43
+ * setup_aruba
44
+ """
45
+
46
+ @ignore-platform-java
47
+ Scenario: Has history
48
+ Given I run `aruba console` interactively
49
+ And I type "aruba_methods"
50
+ And I type "exit"
51
+ When I close the stdin stream
52
+ Then the file "~/.aruba_history" should exist
@@ -0,0 +1,38 @@
1
+ Feature: Configure the aruba console history file
2
+
3
+ As a developer
4
+ I want to configure the history file of aruba console
5
+ In order to have a better isolation of tests
6
+
7
+ Background:
8
+ Given I use the fixture "cli-app"
9
+
10
+ Scenario: Default value
11
+ Given a file named "features/support/aruba.rb" with:
12
+ """
13
+ Aruba.configure do |config|
14
+ puts %(The default value is "#{config.console_history_file}")
15
+ end
16
+ """
17
+ When I successfully run `cucumber`
18
+ Then the output should contain:
19
+ """
20
+ The default value is "~/.aruba_history"
21
+ """
22
+
23
+ Scenario: Set some value
24
+ Given a file named "features/support/aruba.rb" with:
25
+ """
26
+ Aruba.configure do |config|
27
+ config.console_history_file = '~/.config/aruba/history.txt'
28
+ end
29
+
30
+ Aruba.configure do |config|
31
+ puts %(The value is "#{config.console_history_file}")
32
+ end
33
+ """
34
+ Then I successfully run `cucumber`
35
+ Then the output should contain:
36
+ """
37
+ The value is "~/.config/aruba/history.txt"
38
+ """
@@ -6,7 +6,6 @@ Feature: Configure timeout for command execution
6
6
 
7
7
  Background:
8
8
  Given I use the fixture "cli-app"
9
- And the default feature-test
10
9
 
11
10
  Scenario: Default value
12
11
  Given a file named "features/support/aruba.rb" with:
@@ -33,6 +32,7 @@ Feature: Configure timeout for command execution
33
32
  config.exit_timeout = 2
34
33
  end
35
34
  """
35
+ And the default feature-test
36
36
  Then I successfully run `cucumber`
37
37
 
38
38
  Scenario: Fails if takes longer
@@ -47,5 +47,6 @@ Feature: Configure timeout for command execution
47
47
  config.exit_timeout = 1
48
48
  end
49
49
  """
50
+ And the default feature-test
50
51
  Then I run `cucumber`
51
52
  And the exit status should be 1
@@ -6,7 +6,6 @@ Feature: Use fixtures path prefix of aruba
6
6
 
7
7
  Background:
8
8
  Given I use the fixture "cli-app"
9
- And the default feature-test
10
9
 
11
10
  Scenario: Default value
12
11
  Given a file named "features/support/aruba.rb" with:
@@ -11,7 +11,6 @@ Feature: Configure the home directory to be used with aruba
11
11
 
12
12
  Background:
13
13
  Given I use the fixture "cli-app"
14
- And the default feature-test
15
14
 
16
15
  Scenario: Default value
17
16
  Given a file named "features/support/aruba.rb" with:
@@ -6,7 +6,6 @@ Feature: Configure timeout for io of commands
6
6
 
7
7
  Background:
8
8
  Given I use the fixture "cli-app"
9
- And the default feature-test
10
9
 
11
10
  Scenario: Default value
12
11
  Given a file named "features/support/aruba.rb" with:
@@ -1,4 +1,4 @@
1
- Feature: Configure if ansi color codes should be stripped off from command output
1
+ Feature: Configure if ansi color codes should be stripped off from command output (deprecated)
2
2
 
3
3
  As a developer
4
4
  I want to strip off ansi color codes
@@ -6,7 +6,6 @@ Feature: Configure if ansi color codes should be stripped off from command outpu
6
6
 
7
7
  Background:
8
8
  Given I use the fixture "cli-app"
9
- And the default feature-test
10
9
 
11
10
  Scenario: Default value
12
11
  Given a file named "features/support/aruba.rb" with:
@@ -0,0 +1,38 @@
1
+ Feature: Configure Log level of aruba logger
2
+
3
+ As a developer
4
+ I want to configure the level of information put to output by logger
5
+ In order to modify the amount of information
6
+
7
+ Background:
8
+ Given I use the fixture "cli-app"
9
+
10
+ Scenario: Default value
11
+ Given a file named "features/support/aruba.rb" with:
12
+ """
13
+ Aruba.configure do |config|
14
+ puts %(The default value is "#{config.log_level}")
15
+ end
16
+ """
17
+ When I successfully run `cucumber`
18
+ Then the output should contain:
19
+ """
20
+ The default value is "info"
21
+ """
22
+
23
+ Scenario: Modify value
24
+ Given a file named "features/support/aruba.rb" with:
25
+ """
26
+ Aruba.configure do |config|
27
+ config.log_level = :warn
28
+ end
29
+
30
+ Aruba.configure do |config|
31
+ puts %(The default value is "#{config.log_level}")
32
+ end
33
+ """
34
+ Then I successfully run `cucumber`
35
+ Then the output should contain:
36
+ """
37
+ The default value is "warn"
38
+ """
@@ -0,0 +1,53 @@
1
+ Feature: Configure the phsical block size of disk
2
+
3
+ As a developer
4
+ I want to configure the physical block size
5
+ In order to make the disk usage work for my application's setup
6
+
7
+ Background:
8
+ Given I use the fixture "cli-app"
9
+
10
+ Scenario: Default value
11
+ Given a file named "features/support/aruba.rb" with:
12
+ """
13
+ Aruba.configure do |config|
14
+ puts %(The default value is "#{config.physical_block_size}")
15
+ end
16
+ """
17
+ When I successfully run `cucumber`
18
+ Then the output should contain:
19
+ """
20
+ The default value is "512"
21
+ """
22
+
23
+ Scenario: Set the block size to something else which is a power of two
24
+ Given a file named "features/support/aruba.rb" with:
25
+ """
26
+ Aruba.configure do |config|
27
+ # use current working directory
28
+ config.physical_block_size = 4096
29
+ end
30
+
31
+ Aruba.configure do |config|
32
+ puts %(The default value is "#{config.physical_block_size}")
33
+ end
34
+ """
35
+ When I successfully run `cucumber`
36
+ Then the output should contain:
37
+ """
38
+ The default value is "4096"
39
+ """
40
+
41
+ Scenario: The value needs to be a power of two, otherwise it will fail
42
+ Given a file named "features/support/aruba.rb" with:
43
+ """
44
+ Aruba.configure do |config|
45
+ config.physical_block_size = 3
46
+ end
47
+ """
48
+ When I run `cucumber`
49
+ Then the output should contain:
50
+ """
51
+ Contract violation for argument
52
+ """
53
+
@@ -0,0 +1,38 @@
1
+ Feature: Configure if ansi color codes should be stripped off from command output
2
+
3
+ As a developer
4
+ I want to strip off ansi color codes
5
+ In order to make checking of those outputs easier
6
+
7
+ Background:
8
+ Given I use the fixture "cli-app"
9
+
10
+ Scenario: Default value
11
+ Given a file named "features/support/aruba.rb" with:
12
+ """
13
+ Aruba.configure do |config|
14
+ puts %(The default value is "#{config.remove_ansi_escape_sequences}")
15
+ end
16
+ """
17
+ When I successfully run `cucumber`
18
+ Then the output should contain:
19
+ """
20
+ The default value is "true"
21
+ """
22
+
23
+ Scenario: Modify value
24
+ Given a file named "features/support/aruba.rb" with:
25
+ """
26
+ Aruba.configure do |config|
27
+ config.remove_ansi_escape_sequences = false
28
+ end
29
+
30
+ Aruba.configure do |config|
31
+ puts %(The value is "#{config.remove_ansi_escape_sequences}")
32
+ end
33
+ """
34
+ Then I successfully run `cucumber`
35
+ And the output should contain:
36
+ """
37
+ The value is "false"
38
+ """
@@ -6,7 +6,6 @@ Feature: Use root directory of aruba
6
6
 
7
7
  Background:
8
8
  Given I use the fixture "cli-app"
9
- And the default feature-test
10
9
 
11
10
  Scenario: Default configuration
12
11
  Given a file named "features/support/aruba.rb" with:
@@ -6,7 +6,6 @@ Feature: Configure working directory of aruba
6
6
 
7
7
  Background:
8
8
  Given I use the fixture "cli-app"
9
- And the default feature-test
10
9
 
11
10
  Scenario: Default value
12
11
  Given a file named "features/support/aruba.rb" with:
@@ -28,5 +27,7 @@ Feature: Configure working directory of aruba
28
27
  config.working_directory = 'tmp/cucumber'
29
28
  end
30
29
  """
30
+ And the default feature-test
31
+ And the default executable
31
32
  When I successfully run `cucumber`
32
33
  Then a directory named "tmp/cucumber" should exist
@@ -32,3 +32,8 @@ cli
32
32
  ### Library
33
33
 
34
34
  You can use `script/console` to load your library.
35
+
36
+ ### Fixture
37
+
38
+ This fixture includes files for `cucumber`- and `rspec`-integration.
39
+
@@ -1,6 +1,6 @@
1
1
  require 'cli/app/version'
2
2
 
3
- if RUBY_VERSION < '1.9'
3
+ if RUBY_VERSION < '1.9.3'
4
4
  ::Dir.glob(::File.expand_path('../**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
5
5
  else
6
6
  ::Dir.glob(File.expand_path('../**/*.rb', __FILE__)).each { |f| require_relative f }
@@ -1,9 +1,8 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
 
3
3
  require 'cli/app'
4
- require 'aruba/rspec'
5
4
 
6
- if RUBY_VERSION < '1.9.'
5
+ if RUBY_VERSION < '1.9.3'
7
6
  ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
8
7
  else
9
8
  ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
@@ -0,0 +1 @@
1
+ require 'aruba/rspec'
@@ -1,6 +1,6 @@
1
1
  require 'cli/app/version'
2
2
 
3
- if RUBY_VERSION < '1.9'
3
+ if RUBY_VERSION < '1.9.3'
4
4
  ::Dir.glob(::File.expand_path('../**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
5
5
  else
6
6
  ::Dir.glob(File.expand_path('../**/*.rb', __FILE__)).each { |f| require_relative f }
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
 
3
3
  require 'cli/app'
4
4
 
5
- if RUBY_VERSION < '1.9.'
5
+ if RUBY_VERSION < '1.9.3'
6
6
  ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) }
7
7
  else
8
8
  ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f }
@@ -18,7 +18,7 @@ When /^I set env variable "(\w+)" to "([^"]*)"$/ do |var, value|
18
18
  end
19
19
 
20
20
  Then /^aruba should fail with "([^"]*)"$/ do |error_message|
21
- expect(@aruba_exception.message).to include(Aruba::Platform.unescape(error_message))
21
+ expect(@aruba_exception.message).to include(extract_text(unescape_text(error_message)))
22
22
  end
23
23
 
24
24
  Then /^the following step should fail with Spec::Expectations::ExpectationNotMetError:$/ do |multiline_step|
@@ -78,6 +78,17 @@ Then /^the spec(?:s)? should( not)?(?: all)? pass with:$/ do |negated, string|
78
78
  step 'the output should contain:', string if string
79
79
  end
80
80
 
81
+ Given(/^the default executable$/) do
82
+ step 'an executable named "bin/cli" with:', <<-EOS
83
+ #!/usr/bin/env ruby
84
+
85
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
86
+ require 'cli/app'
87
+
88
+ exit 0
89
+ EOS
90
+ end
91
+
81
92
  Given(/^the default feature-test$/) do
82
93
  step(
83
94
  'a file named "features/default.feature" with:',
@@ -13,7 +13,7 @@ require 'rspec/expectations'
13
13
 
14
14
  Before do |scenario|
15
15
  command_name = if scenario.respond_to?(:feature) && scenario.respond_to?(:name)
16
- "#{scenario.feature.title} #{scenario.name}"
16
+ "#{scenario.feature.name} #{scenario.name}"
17
17
  else
18
18
  raise TypeError.new("Don't know how to extract command name from #{scenario.class}")
19
19
  end