aruba 0.9.0 → 0.10.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Gemfile +2 -0
- data/History.md +23 -1
- data/README.md +2 -2
- data/aruba.gemspec +1 -1
- data/cucumber.yml +4 -0
- data/features/api/command/run.feature +18 -0
- data/features/api/environment/remove_environment_variable.feature +63 -0
- data/features/api/environment/set_environment_variable.feature +47 -10
- data/features/api/{command → text}/extract_text.feature +4 -24
- data/features/api/text/sanitize_text.feature +228 -0
- data/features/api/{command → text}/unescape_text.feature +9 -13
- data/features/cli/init.feature +79 -0
- data/features/commands/output/all_output.feature +1 -0
- data/features/getting_started/supported_testing_frameworks.feature +104 -0
- data/features/output.feature +3 -2
- data/features/step_definitions/aruba_dev_steps.rb +1 -60
- data/features/step_definitions/hooks.rb +6 -0
- data/fixtures/empty-app/README.md +1 -11
- data/lib/aruba/api.rb +2 -0
- data/lib/aruba/api/command.rb +0 -19
- data/lib/aruba/api/deprecated.rb +6 -3
- data/lib/aruba/api/environment.rb +18 -0
- data/lib/aruba/api/filesystem.rb +1 -1
- data/lib/aruba/api/text.rb +41 -0
- data/lib/aruba/cli.rb +11 -0
- data/lib/aruba/console.rb +3 -2
- data/lib/aruba/cucumber.rb +1 -0
- data/lib/aruba/cucumber/command.rb +44 -88
- data/lib/aruba/cucumber/environment.rb +7 -3
- data/lib/aruba/cucumber/file.rb +14 -17
- data/lib/aruba/cucumber/hooks.rb +1 -0
- data/lib/aruba/cucumber/testing_frameworks.rb +95 -0
- data/lib/aruba/initializer.rb +185 -0
- data/lib/aruba/matchers/collection/all.rb +9 -0
- data/lib/aruba/matchers/command/have_output.rb +1 -2
- data/lib/aruba/matchers/command/have_output_on_stderr.rb +1 -2
- data/lib/aruba/matchers/command/have_output_on_stdout.rb +1 -2
- data/lib/aruba/matchers/string.rb +1 -0
- data/lib/aruba/matchers/string/include_output_string.rb +36 -0
- data/lib/aruba/matchers/string/match_output_string.rb +37 -0
- data/lib/aruba/matchers/string/output_string_eq.rb +35 -0
- data/lib/aruba/platforms/local_environment.rb +2 -0
- data/lib/aruba/platforms/unix_environment_variables.rb +10 -0
- data/lib/aruba/platforms/unix_platform.rb +3 -1
- data/lib/aruba/platforms/windows_environment_variables.rb +4 -0
- data/lib/aruba/processes/spawn_process.rb +6 -2
- data/lib/aruba/version.rb +1 -1
- metadata +28 -16
- data/fixtures/empty-app/bin/cli +0 -6
- data/fixtures/empty-app/script/console +0 -14
- data/fixtures/empty-app/spec/spec_helper.rb +0 -9
- data/lib/aruba/matchers/collection/all_objects.rb +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f28f6c27992873436132f1a1026bf1fefca105da
|
4
|
+
data.tar.gz: a84562c8730d436682f1e297e9a1f93e5875cc54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cef82f178232a44414a87e5e4b8f1b7582974b4e1e1517defd7154343a5c21a59778951ef71116dae59ea76870924f9945d35f2e69894c637c4f36448a6a424
|
7
|
+
data.tar.gz: 8cdd376cb0f7f4d2d70e508135e6b679ec288a5cbd55c55ebbe7d58972da4261a9ccec084017ee1fe5f1cc736f9cc434f2357169fdabd7c2f212ed04a5a31646
|
data/.travis.yml
CHANGED
@@ -13,9 +13,15 @@ rvm:
|
|
13
13
|
- jruby-21mode
|
14
14
|
- jruby
|
15
15
|
- rbx
|
16
|
+
- jruby-9.0.0.0
|
17
|
+
- jruby-9.0.0.0-20mode
|
18
|
+
- jruby-9.0.0.0-21mode
|
16
19
|
matrix:
|
17
20
|
allow_failures:
|
18
21
|
- rvm: rbx
|
22
|
+
- rvm: jrbuby-9.0.0.0
|
23
|
+
- rvm: jrbuby-9.0.0.0-20mode
|
24
|
+
- rvm: jrbuby-9.0.0.0-21mode
|
19
25
|
notifications:
|
20
26
|
email:
|
21
27
|
- cukes-devs@googlegroups.com
|
data/Gemfile
CHANGED
data/History.md
CHANGED
@@ -1,5 +1,28 @@
|
|
1
1
|
# Latest Release
|
2
2
|
|
3
|
+
## [v0.10.0.pre](https://github.com/cucumber/aruba/compare/v0.9.0...v0.10.0)
|
4
|
+
|
5
|
+
* Add some new steps to make writing documentation easier using "cucumber",
|
6
|
+
"rspec", "minitest" together with "aruba" - see [Feature](features/getting_started/supported_testing_frameworks.feature)
|
7
|
+
for some examples
|
8
|
+
* Write output of commands directly to disk if SpawnProcess is used (see https://github.com/cucumber/aruba/commit/85d74fcca4fff4e753776925d8b003cddaa8041d)
|
9
|
+
* Refactored API of cucumber steps to reduce the need for more methods and make
|
10
|
+
it easier for users to write their own steps (issue #306)
|
11
|
+
* Added `aruba init` to the cli command to setup environment for aruba (issue
|
12
|
+
#308)
|
13
|
+
* Added new method `delete_environment_variable` to remove environment variable
|
14
|
+
* Added work around because of method name conflict between Capybara and RSpec
|
15
|
+
(https://github.com/cucumber/aruba/commit/1939c4049d5195ffdd967485f50119bdd86e98a0)
|
16
|
+
|
17
|
+
# Old releases
|
18
|
+
|
19
|
+
## [v0.9.0](https://github.com/cucumber/aruba/compare/v0.9.0.pre2...v0.9.0)
|
20
|
+
|
21
|
+
* Fix feature test
|
22
|
+
* Fix ordering in console
|
23
|
+
* Fix bug in console handling SIGINT
|
24
|
+
* Deprecated Aruba/Reporting before we remove it
|
25
|
+
|
3
26
|
## [v0.9.0.pre2](https://github.com/cucumber/aruba/compare/v0.9.0.pre...v0.9.0.pre2)
|
4
27
|
|
5
28
|
* Redefine #to_s and #inspect for BasicProcess to reduce the sheer amount of
|
@@ -20,7 +43,6 @@
|
|
20
43
|
* Now we make the process started via `SpawnProcess` the leader of the group to
|
21
44
|
kill all sub-processes more reliably
|
22
45
|
|
23
|
-
# Old releases
|
24
46
|
|
25
47
|
## [v0.9.0.pre](https://github.com/cucumber/aruba/compare/v0.8.1...v0.9.0.pre)
|
26
48
|
|
data/README.md
CHANGED
@@ -9,11 +9,11 @@ Linux / OS X | Windows
|
|
9
9
|
------------- | -------------
|
10
10
|
[![Build Status](https://travis-ci.org/cucumber/aruba.svg)](http://travis-ci.org/cucumber/aruba) | [![Build status](https://ci.appveyor.com/api/projects/status/jfo2tkqhnrqqcivl?svg=true)](https://ci.appveyor.com/project/cucumberbdd/aruba/branch/master)
|
11
11
|
|
12
|
-
`aruba` is an extension for popular TDD and BDD frameworks like "Cucumber" and "
|
12
|
+
`aruba` is an extension for popular TDD and BDD frameworks like "Cucumber", "RSpec" and "Minitest" to make testing of commandline applications meaningful, easy and fun.
|
13
13
|
|
14
14
|
Features at a glance:
|
15
15
|
|
16
|
-
* Test any command line application, implemented in any programming language - e.g. Bash, Python, Ruby, Java
|
16
|
+
* Test any command line application, implemented in any [programming language](features/getting_started/supported_programming_languages.feature) - e.g. Bash, Python, Ruby, Java, ...
|
17
17
|
* Manipulate the file system and the process environment
|
18
18
|
* Automatically reset state of file system and process environment between tests
|
19
19
|
|
data/aruba.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.name = 'aruba'
|
8
8
|
s.version = Aruba::VERSION
|
9
9
|
s.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak", "Matt Wynne", "Jarl Friis", "Dennis Günnewig"]
|
10
|
-
s.description = 'Extension for popular TDD and BDD frameworks like "Cucumber" and "
|
10
|
+
s.description = 'Extension for popular TDD and BDD frameworks like "Cucumber", "RSpec" and "Minitest" to make testing commandline applications meaningful, easy and fun.'
|
11
11
|
s.summary = "aruba-#{s.version}"
|
12
12
|
s.license = 'MIT'
|
13
13
|
s.email = 'cukes@googlegroups.com'
|
data/cucumber.yml
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
<%
|
2
|
+
$LOAD_PATH << ::File.expand_path('../lib', __FILE__)
|
3
|
+
require 'aruba/version'
|
2
4
|
require 'ffi'
|
5
|
+
|
3
6
|
java_version = (RUBY_DESCRIPTION.match(/.*?on.*?(1\.[\d]\..*? )/))[1] if defined?(JRUBY_VERSION)
|
4
7
|
|
5
8
|
std_opts = "--color --exclude features/fixtures --require features --tags ~@unsupported-on"
|
@@ -16,6 +19,7 @@ ignore_opts << '--tags ~@unsupported-on-platform-mac' if FFI::Platform.mac?
|
|
16
19
|
ignore_opts << '--tags ~@unsupported-on-ruby-older-2' if RUBY_VERSION < '2'
|
17
20
|
ignore_opts << '--tags ~@unsupported-on-ruby-older-193' if RUBY_VERSION < '1.9.3'
|
18
21
|
ignore_opts << '--tags ~@unsupported-on-ruby-older-19' if RUBY_VERSION < '1.9'
|
22
|
+
ignore_opts << '--tags ~@requires-aruba-version-1' if Aruba::VERSION < '1'
|
19
23
|
ignore_opts = ignore_opts.join(' ')
|
20
24
|
%>
|
21
25
|
default: <%= std_opts %> --tags ~@wip <%= java_default_opts %> <%= ignore_opts %>
|
@@ -23,6 +23,24 @@ Feature: Run command
|
|
23
23
|
When I run `rspec`
|
24
24
|
Then the specs should all pass
|
25
25
|
|
26
|
+
Scenario: Relative path to executable
|
27
|
+
Given an executable named "bin/cli" with:
|
28
|
+
"""bash
|
29
|
+
#!/bin/bash
|
30
|
+
exit 0
|
31
|
+
"""
|
32
|
+
And a file named "spec/run_spec.rb" with:
|
33
|
+
"""ruby
|
34
|
+
require 'spec_helper'
|
35
|
+
|
36
|
+
RSpec.describe 'Run command', :type => :aruba do
|
37
|
+
before(:each) { run('bin/cli') }
|
38
|
+
it { expect(last_command_started).to be_successfully_executed }
|
39
|
+
end
|
40
|
+
"""
|
41
|
+
When I run `rspec`
|
42
|
+
Then the specs should all pass
|
43
|
+
|
26
44
|
Scenario: Non-existing executable
|
27
45
|
Given a file named "bin/cli" does not exist
|
28
46
|
And a file named "spec/run_spec.rb" with:
|
@@ -0,0 +1,63 @@
|
|
1
|
+
Feature: Remove existing environment variable via API-method
|
2
|
+
|
3
|
+
It is quite handy to modify the environment of a process. To make this
|
4
|
+
possible, `aruba` provides several methods. One of these is
|
5
|
+
`#delete_environment_variable`. Using this remove an existing variable.
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use the fixture "cli-app"
|
9
|
+
|
10
|
+
Scenario: Non-existing variable
|
11
|
+
Given a file named "spec/environment_spec.rb" with:
|
12
|
+
"""ruby
|
13
|
+
require 'spec_helper'
|
14
|
+
|
15
|
+
RSpec.describe 'Long running command', :type => :aruba do
|
16
|
+
before(:each) { delete_environment_variable 'LONG_LONG_VARIABLE' }
|
17
|
+
|
18
|
+
before(:each) { run('env') }
|
19
|
+
before(:each) { stop_all_commands }
|
20
|
+
|
21
|
+
it { expect(last_command_started.output).not_to include 'LONG_LONG_VARIABLE=1' }
|
22
|
+
end
|
23
|
+
"""
|
24
|
+
When I run `rspec`
|
25
|
+
Then the specs should all pass
|
26
|
+
|
27
|
+
Scenario: Existing variable set from within the test
|
28
|
+
Given a file named "spec/environment_spec.rb" with:
|
29
|
+
"""ruby
|
30
|
+
require 'spec_helper'
|
31
|
+
|
32
|
+
RSpec.describe 'Long running command', :type => :aruba do
|
33
|
+
before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '1' }
|
34
|
+
before(:each) { delete_environment_variable 'LONG_LONG_VARIABLE' }
|
35
|
+
|
36
|
+
before(:each) { run('env') }
|
37
|
+
before(:each) { stop_all_commands }
|
38
|
+
|
39
|
+
it { expect(last_command_started.output).not_to include 'LONG_LONG_VARIABLE' }
|
40
|
+
end
|
41
|
+
"""
|
42
|
+
When I run `rspec`
|
43
|
+
Then the specs should all pass
|
44
|
+
|
45
|
+
Scenario: Existing variable set by some outer parent process
|
46
|
+
|
47
|
+
Given a file named "spec/environment_spec.rb" with:
|
48
|
+
"""ruby
|
49
|
+
require 'spec_helper'
|
50
|
+
|
51
|
+
ENV['REALLY_LONG_LONG_VARIABLE'] = '1'
|
52
|
+
|
53
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
54
|
+
before(:each) { delete_environment_variable 'REALLY_LONG_LONG_VARIABLE' }
|
55
|
+
|
56
|
+
before(:each) { run('env') }
|
57
|
+
before(:each) { stop_all_commands }
|
58
|
+
|
59
|
+
it { expect(last_command_started.output).not_to include 'REALLY_LONG_LONG_VARIABLE' }
|
60
|
+
end
|
61
|
+
"""
|
62
|
+
When I run `rspec`
|
63
|
+
Then the specs should all pass
|
@@ -2,7 +2,7 @@ Feature: Set environment variable via API-method
|
|
2
2
|
|
3
3
|
It is quite handy to modify the environment of a process. To make this
|
4
4
|
possible, `aruba` provides several methods. One of these is
|
5
|
-
`#set_environment_variable`. Using this
|
5
|
+
`#set_environment_variable`. Using this sets the value of a
|
6
6
|
non-existing variable and overwrites an existing value. Each variable name
|
7
7
|
and each value is converted to a string. Otherwise `ruby` would complain
|
8
8
|
about an invalid argument. To make use of a variable you can either use `#run`
|
@@ -17,7 +17,7 @@ Feature: Set environment variable via API-method
|
|
17
17
|
"""ruby
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
|
-
RSpec.describe '
|
20
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
21
21
|
before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '1' }
|
22
22
|
|
23
23
|
before(:each) { run('env') }
|
@@ -34,7 +34,7 @@ Feature: Set environment variable via API-method
|
|
34
34
|
"""ruby
|
35
35
|
require 'spec_helper'
|
36
36
|
|
37
|
-
RSpec.describe '
|
37
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
38
38
|
before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '1' }
|
39
39
|
before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '2' }
|
40
40
|
|
@@ -56,7 +56,7 @@ Feature: Set environment variable via API-method
|
|
56
56
|
|
57
57
|
ENV['REALLY_LONG_LONG_VARIABLE'] = '1'
|
58
58
|
|
59
|
-
RSpec.describe '
|
59
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
60
60
|
before(:each) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '2' }
|
61
61
|
|
62
62
|
before(:each) { run('env') }
|
@@ -80,7 +80,7 @@ Feature: Set environment variable via API-method
|
|
80
80
|
|
81
81
|
ENV['REALLY_LONG_LONG_VARIABLE'] = '1'
|
82
82
|
|
83
|
-
RSpec.describe '
|
83
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
84
84
|
before(:each) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '2' }
|
85
85
|
|
86
86
|
before(:each) { run('env') }
|
@@ -110,7 +110,7 @@ Feature: Set environment variable via API-method
|
|
110
110
|
|
111
111
|
ENV['REALLY_LONG_LONG_VARIABLE'] = '1'
|
112
112
|
|
113
|
-
RSpec.describe '
|
113
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
114
114
|
before(:each) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '2' }
|
115
115
|
|
116
116
|
before(:each) { run('env') }
|
@@ -137,7 +137,7 @@ Feature: Set environment variable via API-method
|
|
137
137
|
"""ruby
|
138
138
|
require 'spec_helper'
|
139
139
|
|
140
|
-
RSpec.describe '
|
140
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
141
141
|
before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '1' }
|
142
142
|
|
143
143
|
describe 'Method XX' do
|
@@ -167,7 +167,7 @@ Feature: Set environment variable via API-method
|
|
167
167
|
|
168
168
|
ENV['REALLY_LONG_LONG_VARIABLE'] = '1'
|
169
169
|
|
170
|
-
RSpec.describe '
|
170
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
171
171
|
before(:each) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '2' }
|
172
172
|
|
173
173
|
before(:each) { run('env') }
|
@@ -203,7 +203,7 @@ Feature: Set environment variable via API-method
|
|
203
203
|
ENV['LONG_LONG_VARIABLE'] = '1'
|
204
204
|
ENV['REALLY_LONG_LONG_VARIABLE'] = '1'
|
205
205
|
|
206
|
-
RSpec.describe '
|
206
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
207
207
|
it do
|
208
208
|
with_environment 'REALLY_LONG_LONG_VARIABLE' => 2 do
|
209
209
|
with_environment 'LONG_LONG_VARIABLE' => 3 do
|
@@ -230,7 +230,7 @@ Feature: Set environment variable via API-method
|
|
230
230
|
"""ruby
|
231
231
|
require 'spec_helper'
|
232
232
|
|
233
|
-
RSpec.describe '
|
233
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
234
234
|
# Please mind :context. This is run BEFORE the `around`-hook
|
235
235
|
before(:context) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '1' }
|
236
236
|
|
@@ -267,3 +267,40 @@ Feature: Set environment variable via API-method
|
|
267
267
|
"""
|
268
268
|
When I run `rspec`
|
269
269
|
Then the specs should all pass
|
270
|
+
|
271
|
+
@unsupported-on-platform-windows
|
272
|
+
Scenario: Mixed-Case variable
|
273
|
+
Given a file named "spec/environment_spec.rb" with:
|
274
|
+
"""ruby
|
275
|
+
require 'spec_helper'
|
276
|
+
|
277
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
278
|
+
before(:each) { set_environment_variable 'long_LONG_VARIABLE', '1' }
|
279
|
+
|
280
|
+
before(:each) { run('env') }
|
281
|
+
before(:each) { stop_all_commands }
|
282
|
+
|
283
|
+
it { expect(last_command_started.output).to include 'long_LONG_VARIABLE=1' }
|
284
|
+
end
|
285
|
+
"""
|
286
|
+
When I run `rspec`
|
287
|
+
Then the specs should all pass
|
288
|
+
|
289
|
+
@unsupported-on-platform-unix
|
290
|
+
@unsupported-on-platform-mac
|
291
|
+
Scenario: Mixed-Case variable
|
292
|
+
Given a file named "spec/environment_spec.rb" with:
|
293
|
+
"""ruby
|
294
|
+
require 'spec_helper'
|
295
|
+
|
296
|
+
RSpec.describe 'Environment command', :type => :aruba do
|
297
|
+
before(:each) { set_environment_variable 'long_LONG_VARIABLE', '1' }
|
298
|
+
|
299
|
+
before(:each) { run('env') }
|
300
|
+
before(:each) { stop_all_commands }
|
301
|
+
|
302
|
+
it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=1' }
|
303
|
+
end
|
304
|
+
"""
|
305
|
+
When I run `rspec`
|
306
|
+
Then the specs should all pass
|
@@ -12,7 +12,7 @@ Feature: Extract text from output
|
|
12
12
|
#!/bin/bash
|
13
13
|
echo -n "\e[31mText"
|
14
14
|
"""
|
15
|
-
And a file named "spec/
|
15
|
+
And a file named "spec/extract_text_spec.rb" with:
|
16
16
|
"""
|
17
17
|
require 'spec_helper'
|
18
18
|
|
@@ -32,7 +32,7 @@ Feature: Extract text from output
|
|
32
32
|
#!/bin/bash
|
33
33
|
echo -n "\033[31mText"
|
34
34
|
"""
|
35
|
-
And a file named "spec/
|
35
|
+
And a file named "spec/extract_text_spec.rb" with:
|
36
36
|
"""
|
37
37
|
require 'spec_helper'
|
38
38
|
|
@@ -46,33 +46,13 @@ Feature: Extract text from output
|
|
46
46
|
When I run `rspec`
|
47
47
|
Then the specs should all pass
|
48
48
|
|
49
|
-
# Scenario: Output contains ansi escape codes enclosed by \[\]
|
50
|
-
# Given an executable named "bin/cli" with:
|
51
|
-
# """
|
52
|
-
# #!/bin/bash
|
53
|
-
# echo -n "\[\033[31m\]Text"
|
54
|
-
# """
|
55
|
-
# And a file named "spec/which_spec.rb" with:
|
56
|
-
# """
|
57
|
-
# require 'spec_helper'
|
58
|
-
#
|
59
|
-
# RSpec.describe 'Run command', :type => :aruba do
|
60
|
-
# before(:each) { run('cli') }
|
61
|
-
# before(:each) { stop_all_commands }
|
62
|
-
#
|
63
|
-
# it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" }
|
64
|
-
# end
|
65
|
-
# """
|
66
|
-
# When I run `rspec`
|
67
|
-
# Then the specs should all pass
|
68
|
-
|
69
49
|
# Scenario: Output contains ansi escape code \016
|
70
50
|
# Given an executable named "bin/cli" with:
|
71
51
|
# """
|
72
52
|
# #!/bin/bash
|
73
53
|
# echo -n "\016Text"
|
74
54
|
# """
|
75
|
-
# And a file named "spec/
|
55
|
+
# And a file named "spec/extract_text_spec.rb" with:
|
76
56
|
# """
|
77
57
|
# require 'spec_helper'
|
78
58
|
#
|
@@ -92,7 +72,7 @@ Feature: Extract text from output
|
|
92
72
|
# #!/bin/bash
|
93
73
|
# echo -n "\017Text"
|
94
74
|
# """
|
95
|
-
# And a file named "spec/
|
75
|
+
# And a file named "spec/extract_text_spec.rb" with:
|
96
76
|
# """
|
97
77
|
# require 'spec_helper'
|
98
78
|
#
|
@@ -0,0 +1,228 @@
|
|
1
|
+
Feature: Sanitize text from output
|
2
|
+
|
3
|
+
If have got some text include \n, \t and the like and need them to become
|
4
|
+
special characters again and also want the text to be stripped down to bare
|
5
|
+
text, you can use the `#sanitize_text`-method for this.
|
6
|
+
|
7
|
+
Background:
|
8
|
+
Given I use a fixture named "cli-app"
|
9
|
+
|
10
|
+
Scenario: Output contains \n
|
11
|
+
Given an executable named "bin/cli" with:
|
12
|
+
"""
|
13
|
+
#!/bin/bash
|
14
|
+
echo -n 'text\ntext'
|
15
|
+
"""
|
16
|
+
And a file named "spec/sanitize_spec.rb" with:
|
17
|
+
"""
|
18
|
+
require 'spec_helper'
|
19
|
+
|
20
|
+
RSpec.describe 'Run command', :type => :aruba do
|
21
|
+
before(:each) { run('cli') }
|
22
|
+
before(:each) { stop_all_commands }
|
23
|
+
|
24
|
+
it { expect(sanitize_text(last_command_started.output)).to eq "text\ntext" }
|
25
|
+
end
|
26
|
+
"""
|
27
|
+
When I run `rspec`
|
28
|
+
Then the specs should all pass
|
29
|
+
|
30
|
+
Scenario: Output contains \e
|
31
|
+
Given an executable named "bin/cli" with:
|
32
|
+
"""
|
33
|
+
#!/bin/bash
|
34
|
+
echo -n 'text\etext'
|
35
|
+
"""
|
36
|
+
And a file named "spec/sanitize_spec.rb" with:
|
37
|
+
"""
|
38
|
+
require 'spec_helper'
|
39
|
+
|
40
|
+
RSpec.describe 'Run command', :type => :aruba do
|
41
|
+
before(:each) { run('cli') }
|
42
|
+
before(:each) { stop_all_commands }
|
43
|
+
|
44
|
+
it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
|
45
|
+
end
|
46
|
+
"""
|
47
|
+
When I run `rspec`
|
48
|
+
Then the specs should all pass
|
49
|
+
|
50
|
+
Scenario: Output contains \"
|
51
|
+
Given an executable named "bin/cli" with:
|
52
|
+
"""
|
53
|
+
#!/bin/bash
|
54
|
+
echo -n 'text\"text'
|
55
|
+
"""
|
56
|
+
And a file named "spec/sanitize_spec.rb" with:
|
57
|
+
"""
|
58
|
+
require 'spec_helper'
|
59
|
+
|
60
|
+
RSpec.describe 'Run command', :type => :aruba do
|
61
|
+
before(:each) { run('cli') }
|
62
|
+
before(:each) { stop_all_commands }
|
63
|
+
|
64
|
+
it { expect(sanitize_text(last_command_started.output)).to eq "text\"text" }
|
65
|
+
end
|
66
|
+
"""
|
67
|
+
When I run `rspec`
|
68
|
+
Then the specs should all pass
|
69
|
+
|
70
|
+
Scenario: Output contains \033
|
71
|
+
Given an executable named "bin/cli" with:
|
72
|
+
"""
|
73
|
+
#!/bin/bash
|
74
|
+
echo -n 'text\033text'
|
75
|
+
"""
|
76
|
+
And a file named "spec/sanitize_spec.rb" with:
|
77
|
+
"""
|
78
|
+
require 'spec_helper'
|
79
|
+
|
80
|
+
RSpec.describe 'Run command', :type => :aruba do
|
81
|
+
before(:each) { run('cli') }
|
82
|
+
before(:each) { stop_all_commands }
|
83
|
+
|
84
|
+
it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
|
85
|
+
end
|
86
|
+
"""
|
87
|
+
When I run `rspec`
|
88
|
+
Then the specs should all pass
|
89
|
+
|
90
|
+
Scenario: Output contains \017
|
91
|
+
Given an executable named "bin/cli" with:
|
92
|
+
"""
|
93
|
+
#!/bin/bash
|
94
|
+
echo -n 'text\017text'
|
95
|
+
"""
|
96
|
+
And a file named "spec/sanitize_spec.rb" with:
|
97
|
+
"""
|
98
|
+
require 'spec_helper'
|
99
|
+
|
100
|
+
RSpec.describe 'Run command', :type => :aruba do
|
101
|
+
before(:each) { run('cli') }
|
102
|
+
before(:each) { stop_all_commands }
|
103
|
+
|
104
|
+
it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
|
105
|
+
end
|
106
|
+
"""
|
107
|
+
When I run `rspec`
|
108
|
+
Then the specs should all pass
|
109
|
+
|
110
|
+
Scenario: Output contains \016
|
111
|
+
Given an executable named "bin/cli" with:
|
112
|
+
"""
|
113
|
+
#!/bin/bash
|
114
|
+
echo -n 'text\016text'
|
115
|
+
"""
|
116
|
+
And a file named "spec/sanitize_spec.rb" with:
|
117
|
+
"""
|
118
|
+
require 'spec_helper'
|
119
|
+
|
120
|
+
RSpec.describe 'Run command', :type => :aruba do
|
121
|
+
before(:each) { run('cli') }
|
122
|
+
before(:each) { stop_all_commands }
|
123
|
+
|
124
|
+
it { expect(sanitize_text(last_command_started.output)).to eq "texttext" }
|
125
|
+
end
|
126
|
+
"""
|
127
|
+
When I run `rspec`
|
128
|
+
Then the specs should all pass
|
129
|
+
|
130
|
+
Scenario: Output contains ansi escape codes prefixed by \e
|
131
|
+
Given an executable named "bin/cli" with:
|
132
|
+
"""
|
133
|
+
#!/bin/bash
|
134
|
+
echo -n "\e[31mText"
|
135
|
+
"""
|
136
|
+
And a file named "spec/sanitize_spec.rb" with:
|
137
|
+
"""
|
138
|
+
require 'spec_helper'
|
139
|
+
|
140
|
+
RSpec.describe 'Run command', :type => :aruba do
|
141
|
+
before(:each) { run('cli') }
|
142
|
+
before(:each) { stop_all_commands }
|
143
|
+
|
144
|
+
it { expect(sanitize_text(last_command_started.output)).to eq "Text" }
|
145
|
+
end
|
146
|
+
"""
|
147
|
+
When I run `rspec`
|
148
|
+
Then the specs should all pass
|
149
|
+
|
150
|
+
Scenario: Output contains ansi escape codes prefixed by \033
|
151
|
+
Given an executable named "bin/cli" with:
|
152
|
+
"""
|
153
|
+
#!/bin/bash
|
154
|
+
echo -n "\033[31mText"
|
155
|
+
"""
|
156
|
+
And a file named "spec/sanitize_spec.rb" with:
|
157
|
+
"""
|
158
|
+
require 'spec_helper'
|
159
|
+
|
160
|
+
RSpec.describe 'Run command', :type => :aruba do
|
161
|
+
before(:each) { run('cli') }
|
162
|
+
before(:each) { stop_all_commands }
|
163
|
+
|
164
|
+
it { expect(sanitize_text(last_command_started.output)).to eq "Text" }
|
165
|
+
end
|
166
|
+
"""
|
167
|
+
When I run `rspec`
|
168
|
+
Then the specs should all pass
|
169
|
+
|
170
|
+
Scenario: Output contains ansi escape codes prefixed by \e, but removable is disabled by configuration
|
171
|
+
Given an executable named "bin/cli" with:
|
172
|
+
"""
|
173
|
+
#!/bin/bash
|
174
|
+
echo -n "\e[31mText"
|
175
|
+
"""
|
176
|
+
And a file named "spec/sanitize_spec.rb" with:
|
177
|
+
"""
|
178
|
+
require 'spec_helper'
|
179
|
+
|
180
|
+
RSpec.describe 'Run command', :type => :aruba, :remove_ansi_escape_sequences => false, :keep_ansi => true do
|
181
|
+
before(:each) { run('cli') }
|
182
|
+
before(:each) { stop_all_commands }
|
183
|
+
|
184
|
+
it { expect(sanitize_text(last_command_started.output)).to eq "\e[31mText" }
|
185
|
+
end
|
186
|
+
"""
|
187
|
+
When I run `rspec`
|
188
|
+
Then the specs should all pass
|
189
|
+
|
190
|
+
# Scenario: Output contains ansi escape code \016
|
191
|
+
# Given an executable named "bin/cli" with:
|
192
|
+
# """
|
193
|
+
# #!/bin/bash
|
194
|
+
# echo -n "\016Text"
|
195
|
+
# """
|
196
|
+
# And a file named "spec/sanitize_spec.rb" with:
|
197
|
+
# """
|
198
|
+
# require 'spec_helper'
|
199
|
+
#
|
200
|
+
# RSpec.describe 'Run command', :type => :aruba do
|
201
|
+
# before(:each) { run('cli') }
|
202
|
+
# before(:each) { stop_all_commands }
|
203
|
+
#
|
204
|
+
# it { expect(sanitize_text(last_command_started.output)).to eq "Text" }
|
205
|
+
# end
|
206
|
+
# """
|
207
|
+
# When I run `rspec`
|
208
|
+
# Then the specs should all pass
|
209
|
+
|
210
|
+
# Scenario: Output contains ansi escape code \017
|
211
|
+
# Given an executable named "bin/cli" with:
|
212
|
+
# """
|
213
|
+
# #!/bin/bash
|
214
|
+
# echo -n "\017Text"
|
215
|
+
# """
|
216
|
+
# And a file named "spec/sanitize_spec.rb" with:
|
217
|
+
# """
|
218
|
+
# require 'spec_helper'
|
219
|
+
#
|
220
|
+
# RSpec.describe 'Run command', :type => :aruba do
|
221
|
+
# before(:each) { run('cli') }
|
222
|
+
# before(:each) { stop_all_commands }
|
223
|
+
#
|
224
|
+
# it { expect(sanitize_text(last_command_started.output)).to eq "Text" }
|
225
|
+
# end
|
226
|
+
# """
|
227
|
+
# When I run `rspec`
|
228
|
+
# Then the specs should all pass
|