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
@@ -38,6 +38,22 @@ Feature: Expand paths with aruba
38
38
  When I run `rspec`
39
39
  Then the specs should all pass
40
40
 
41
+ Scenario: Warn if aruba's working directory does not exist
42
+ Given a file named "spec/expand_path_spec.rb" with:
43
+ """
44
+ require 'spec_helper'
45
+
46
+ RSpec.describe 'Expand path', :type => :aruba do
47
+ before(:each) { remove('.') }
48
+
49
+ let(:path) { 'path/to/dir' }
50
+
51
+ it { expect { expand_path(path) }.to output(/working directory does not exist/).to_stderr }
52
+ end
53
+ """
54
+ When I run `rspec`
55
+ Then the specs should all pass
56
+
41
57
  Scenario: Use ~ in path
42
58
 
43
59
  Now this useses the HOME-variable from your normal shell HOME-variable.
@@ -42,6 +42,7 @@ Feature: Change current working directory
42
42
  before(:each) { run_simple 'pwd' }
43
43
 
44
44
  it { expect(last_command.output).to include 'new_dir.d' }
45
+ it { expect(last_command).to be_executed_in_time }
45
46
  end
46
47
  """
47
48
  When I run `rspec`
@@ -162,7 +163,7 @@ Feature: Change current working directory
162
163
 
163
164
  before :each do
164
165
  @pwd = cd('new_dir.d') do
165
- cd('subdir.d') { run('pwd') }
166
+ cd('subdir.d') { run_simple('pwd') }
166
167
  end
167
168
  end
168
169
 
@@ -0,0 +1,57 @@
1
+ Feature: Create Directory
2
+
3
+ Use the `#create_directory`-method to create a directory within `aruba`'s
4
+ working directory.
5
+
6
+ ```ruby
7
+ require 'spec_helper'
8
+
9
+ RSpec.configure do |config|
10
+ config.include Aruba::Api
11
+ end
12
+
13
+ RSpec.describe 'Create directory' do
14
+ let(:directory) { 'dir.d' }
15
+ before(:each) { create_directory(directory) }
16
+
17
+ it { expect(directory).to be_an_existing_directory }
18
+ end
19
+ ```
20
+
21
+ Background:
22
+ Given I use a fixture named "cli-app"
23
+
24
+ Scenario: New directory
25
+ Given a file named "spec/create_directory_spec.rb" with:
26
+ """
27
+ require 'spec_helper'
28
+
29
+ RSpec.describe 'Create directory', :type => :aruba do
30
+ let(:directory) { 'dir.d' }
31
+ before(:each) { create_directory(directory) }
32
+
33
+ it { expect(directory).to be_an_existing_directory }
34
+ end
35
+ """
36
+ When I run `rspec`
37
+ Then the specs should all pass
38
+
39
+ Scenario: Existing directory
40
+
41
+ It does not complain if a directory already exists.
42
+
43
+ Given a file named "spec/create_directory_spec.rb" with:
44
+ """
45
+ require 'spec_helper'
46
+
47
+ RSpec.describe 'Create directory', :type => :aruba do
48
+ let(:directory) { 'dir.d' }
49
+
50
+ before(:each) { create_directory(directory) }
51
+ before(:each) { create_directory(directory) }
52
+
53
+ it { expect(directory).to be_an_existing_directory }
54
+ end
55
+ """
56
+ When I run `rspec`
57
+ Then the specs should all pass
@@ -0,0 +1,151 @@
1
+ Feature: Report disk usage
2
+
3
+ Sometimes you need to check, what amount of disk space a file consumes. We do
4
+ NOT support "directories" with `#disk_usage`. This does not work reliably
5
+ over different systems. Here can help `'#disk_usage`. But be careful, by
6
+ default it uses a block size of "512" (physical block size) to calculate the
7
+ usage. You may need to adjust this by using `Aruba.configure { |config|
8
+ config.physical_block_size = 4_096 }`. Don't get confused, if you check the
9
+ block size by using `File::Stat` (in ruby). It reports the block size of your
10
+ filesystem, which can be "4_096" for example.
11
+
12
+ We're gonna use the (correct) IEC-notation
13
+ (https://en.wikipedia.org/wiki/Binary_prefix) here:
14
+
15
+ \* kilo => kibi
16
+ \* mega => mebi
17
+ \* giga => gibi
18
+
19
+ Background:
20
+ Given I use a fixture named "cli-app"
21
+
22
+ Scenario: Show disk usage for file
23
+ Given a file named "spec/disk_usage_spec.rb" with:
24
+ """
25
+ require 'spec_helper'
26
+
27
+ RSpec.describe 'disk usage', :type => :aruba do
28
+ let(:file) { 'file.txt' }
29
+
30
+ before(:each) do
31
+ write_file file, 'a'
32
+ end
33
+
34
+ let(:size_of_single_block) { File::Stat.new(expand_path(file)).blksize }
35
+
36
+ it { expect(disk_usage(file)).to eq size_of_single_block }
37
+ end
38
+ """
39
+ When I run `rspec`
40
+ Then the specs should all pass
41
+
42
+ Scenario: Show disk usage for multiple files
43
+
44
+ `#disk_usage` creates the sum of all given objects' sizes.
45
+
46
+ Given a file named "spec/disk_usage_spec.rb" with:
47
+ """
48
+ require 'spec_helper'
49
+
50
+ RSpec.describe 'disk usage', :type => :aruba do
51
+ let(:file1) { 'file1.txt' }
52
+ let(:file2) { 'file2.txt' }
53
+
54
+ before(:each) do
55
+ write_file file1, 'a'
56
+ write_file file2, 'a'
57
+ end
58
+
59
+ let(:size_of_single_block) { File::Stat.new(expand_path(file1)).blksize }
60
+
61
+ it { expect(disk_usage(file1, file2)).to eq size_of_single_block * 2 }
62
+ it { expect(disk_usage([file1, file2])).to eq size_of_single_block * 2 }
63
+ end
64
+ """
65
+ When I run `rspec`
66
+ Then the specs should all pass
67
+
68
+ Scenario: Convert reported disk usage to KibiByte
69
+ Given a file named "spec/disk_usage_spec.rb" with:
70
+ """
71
+ require 'spec_helper'
72
+
73
+ RSpec.describe 'disk usage', :type => :aruba do
74
+ let(:file) { 'file.txt' }
75
+
76
+ before(:each) do
77
+ write_file file, 'a'
78
+ end
79
+
80
+ let(:converted_size) { File::Stat.new(expand_path(file)).blksize.to_f / 1_024 }
81
+
82
+ it { expect(disk_usage(file).to_kibi_byte).to eq converted_size }
83
+ end
84
+ """
85
+ When I run `rspec`
86
+ Then the specs should all pass
87
+
88
+ Scenario: Convert reported disk usage to MebiByte
89
+ Given a file named "spec/disk_usage_spec.rb" with:
90
+ """
91
+ require 'spec_helper'
92
+
93
+ RSpec.describe 'disk usage', :type => :aruba do
94
+ let(:file) { 'file.txt' }
95
+
96
+ before(:each) do
97
+ write_file file, 'a'
98
+ end
99
+
100
+ let(:converted_size) { File::Stat.new(expand_path(file)).blksize.to_f / 1_024 / 1024 }
101
+
102
+ it { expect(disk_usage(file).to_mebi_byte).to eq converted_size }
103
+ end
104
+ """
105
+ When I run `rspec`
106
+ Then the specs should all pass
107
+
108
+ Scenario: Convert reported disk usage to GibiByte
109
+ Given a file named "spec/disk_usage_spec.rb" with:
110
+ """
111
+ require 'spec_helper'
112
+
113
+ RSpec.describe 'disk usage', :type => :aruba do
114
+ let(:file) { 'file.txt' }
115
+
116
+ before(:each) do
117
+ write_file file, 'a'
118
+ end
119
+
120
+ let(:converted_size) { File::Stat.new(expand_path(file)).blksize.to_f / 1_024 / 1_024 / 1_024 }
121
+
122
+ it { expect(disk_usage(file).to_gibi_byte).to eq converted_size }
123
+ end
124
+ """
125
+ When I run `rspec`
126
+ Then the specs should all pass
127
+
128
+ Scenario: Compare two repored disk usages
129
+ Given a file named "spec/disk_usage_spec.rb" with:
130
+ """
131
+ require 'spec_helper'
132
+
133
+ RSpec.describe 'disk usage', :type => :aruba do
134
+ let(:file1) { 'file1.txt' }
135
+ let(:file2) { 'file2.txt' }
136
+
137
+ before(:each) do
138
+ write_file file1, 'a' * 10_000
139
+ write_file file2, 'a'
140
+ end
141
+
142
+ before :each do
143
+ @size1 = disk_usage(file1)
144
+ @size2 = disk_usage(file2)
145
+ end
146
+
147
+ it { expect(@size1).to be > @size2 }
148
+ end
149
+ """
150
+ When I run `rspec`
151
+ Then the specs should all pass
@@ -0,0 +1,62 @@
1
+ Feature: Check existence of files and directories
2
+
3
+ Use the `#exist?` to check if a path exists within
4
+ `aruba`'s working directory. , May also want to look for `#file?` or
5
+ `#directory?` for some more specific tests.
6
+
7
+ ```ruby
8
+ require 'spec_helper'
9
+
10
+ RSpec.configure do |config|
11
+ config.include Aruba::Api
12
+ end
13
+
14
+ RSpec.describe 'Check if directory and file exist' do
15
+ let(:directory) { 'dir.d' }
16
+ let(:file) { 'file.txt' }
17
+
18
+ before(:each) { create_directory(directory) }
19
+ before(:each) { touch(file) }
20
+
21
+ it { expect(exist?(directory)).to be true }
22
+ it { expect(exist?(file)).to be true }
23
+ end
24
+ ```
25
+
26
+ Background:
27
+ Given I use a fixture named "cli-app"
28
+
29
+ Scenario: Is file or directory and exists
30
+ Given a file named "spec/create_directory_spec.rb" with:
31
+ """
32
+ require 'spec_helper'
33
+
34
+ RSpec.describe 'Check if directory and file exist', :type => :aruba do
35
+ let(:directory) { 'dir.d' }
36
+ let(:file) { 'file.txt' }
37
+
38
+ before(:each) { create_directory(directory) }
39
+ before(:each) { touch(file) }
40
+
41
+ it { expect(exist?(directory)).to be true }
42
+ it { expect(exist?(file)).to be true }
43
+ end
44
+ """
45
+ When I run `rspec`
46
+ Then the specs should all pass
47
+
48
+ Scenario: Is file or directory and does not exist
49
+ Given a file named "spec/create_directory_spec.rb" with:
50
+ """
51
+ require 'spec_helper'
52
+
53
+ RSpec.describe 'Check if directory and file exist', :type => :aruba do
54
+ let(:directory) { 'dir.d' }
55
+ let(:file) { 'file.txt' }
56
+
57
+ it { expect(exist?(directory)).to be false }
58
+ it { expect(exist?(file)).to be false }
59
+ end
60
+ """
61
+ When I run `rspec`
62
+ Then the specs should all pass
@@ -0,0 +1,48 @@
1
+ Feature: Check if path is absolute
2
+
3
+ Use the `#absolute?`-method to check if a path is an absolute 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 absolute' do
13
+ let(:path) { '/path/to/file.txt' }
14
+
15
+ it { expect(absolute?(path)).to be true }
16
+ end
17
+ ```
18
+
19
+ Background:
20
+ Given I use a fixture named "cli-app"
21
+
22
+ Scenario: Is path absolute
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 absolute', :type => :aruba do
28
+ let(:path) { '/path/to/file.txt' }
29
+
30
+ it { expect(absolute?(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 absolute, 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 absolute', :type => :aruba do
42
+ let(:path) { 'file.txt' }
43
+
44
+ it { expect(absolute?(path)).to be false }
45
+ end
46
+ """
47
+ When I run `rspec`
48
+ Then the specs should all pass
@@ -0,0 +1,53 @@
1
+ Feature: Check existence of directories
2
+
3
+ Use the `#directory?` to check if a path is a directory and exists within
4
+ `aruba`'s working directory.
5
+
6
+ ```ruby
7
+ require 'spec_helper'
8
+
9
+ RSpec.configure do |config|
10
+ config.include Aruba::Api
11
+ end
12
+
13
+ RSpec.describe 'Check if directory and file exist' do
14
+ let(:directory) { 'dir.d' }
15
+
16
+ before(:each) { create_directory(directory) }
17
+
18
+ it { expect(directory?(directory)).to be true }
19
+ end
20
+ ```
21
+
22
+ Background:
23
+ Given I use a fixture named "cli-app"
24
+
25
+ Scenario: Is directory and exist
26
+ Given a file named "spec/create_directory_spec.rb" with:
27
+ """
28
+ require 'spec_helper'
29
+
30
+ RSpec.describe 'Check if directory and file exist', :type => :aruba do
31
+ let(:directory) { 'dir.d' }
32
+ before(:each) { create_directory(directory) }
33
+
34
+ it { expect(directory?(directory)).to be true }
35
+ end
36
+ """
37
+ When I run `rspec`
38
+ Then the specs should all pass
39
+
40
+ Scenario: Is file, but should be directory and exist
41
+ Given a file named "spec/create_directory_spec.rb" with:
42
+ """
43
+ require 'spec_helper'
44
+
45
+ RSpec.describe 'Check if directory and file exist', :type => :aruba do
46
+ let(:file) { 'file.txt' }
47
+ before(:each) { touch(file) }
48
+
49
+ it { expect(directory?(file)).to be false }
50
+ end
51
+ """
52
+ When I run `rspec`
53
+ Then the specs should all pass
@@ -0,0 +1,54 @@
1
+ Feature: Check existence of files
2
+
3
+ Use the `#file?` to check if a path is a file and exists within `aruba`'s
4
+ working directory.
5
+
6
+ ```ruby
7
+ require 'spec_helper'
8
+
9
+ RSpec.configure do |config|
10
+ config.include Aruba::Api
11
+ end
12
+
13
+ RSpec.describe 'Check if directory and file exist' do
14
+ let(:file) { 'file.txt' }
15
+
16
+ before(:each) { touch(file) }
17
+
18
+ it { expect(file?(file)).to be true }
19
+ end
20
+ ```
21
+
22
+ Background:
23
+ Given I use a fixture named "cli-app"
24
+
25
+ Scenario: Is file and exist
26
+ Given a file named "spec/create_directory_spec.rb" with:
27
+ """
28
+ require 'spec_helper'
29
+
30
+ RSpec.describe 'Check if directory and file exist', :type => :aruba do
31
+ let(:file) { 'file.txt' }
32
+
33
+ before(:each) { touch(file) }
34
+
35
+ it { expect(file?(file)).to be true }
36
+ end
37
+ """
38
+ When I run `rspec`
39
+ Then the specs should all pass
40
+
41
+ Scenario: Is directory, but should be file and exist
42
+ Given a file named "spec/create_directory_spec.rb" with:
43
+ """
44
+ require 'spec_helper'
45
+
46
+ RSpec.describe 'Check if directory and file exist', :type => :aruba do
47
+ let(:directory) { 'dir.d' }
48
+ before(:each) { create_directory(directory) }
49
+
50
+ it { expect(file?(directory)).to be false }
51
+ end
52
+ """
53
+ When I run `rspec`
54
+ Then the specs should all pass