aruba 0.8.1 → 0.9.0.pre

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 (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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5922faa25f8f714ff4c1e464ef17fd92cb75fb67
4
- data.tar.gz: a0267059c8ec8d97fef445b546ba347bfab4e403
3
+ metadata.gz: 71f21475524ff2255d0cba069a187f55eab76a63
4
+ data.tar.gz: 6b76f7d95d15526e86d3ef939cb317a98dabc5ac
5
5
  SHA512:
6
- metadata.gz: 47bca34dca99c9f86f36412ec3c1e915f233abaf7daa14b37149c6ee3b3b458745045a6fb3b8b260a78756b2ca1547f66a4bc6df502872633227b5e1a20dee2b
7
- data.tar.gz: 96434347a767b0527cbd44a92946a63216a87f67d34ba1e19bac1fc27297256bc5496a7b7f9f4cadf31d9a59ec585edb22943c2f70ed0f22c2888e952b9649ac
6
+ metadata.gz: 03123d44f1928b357d180dfe202d35b2c9e3c6f33a613ee8a60c52744d2a5fd6170e184f76abf826745ca0c98aefab602eafa9fdbf63fa274db88e862013eee1
7
+ data.tar.gz: dbc946f90ee79b79fde4acfa617010bcffc9d7813ad83bf2b966cb1a4f1d6e14ca317e137e14a26a77ad7edc9a4af52c0a25bbfb2cce557cdf2dea1e1bc859c3
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --color
2
+ --format Fuubar
2
3
  --order random
@@ -6,6 +6,7 @@ rvm:
6
6
  - 2.2.2
7
7
  - 2.1.6
8
8
  - 2.0.0
9
+ - 1.9.2
9
10
  - 1.9.3
10
11
  - 1.8.7
11
12
  - jruby-20mode
@@ -22,4 +23,5 @@ notifications:
22
23
  - irc.freenode.org#cucumber
23
24
  env:
24
25
  global:
25
- secure: l8uznA5K4K9mZ1krmP3lTMD8WcJ32qGxFOR3jubKHcOBSLB4xSzU2aIqjyJdO+rLzebkwamhJc8pGSIWOUDQYvFiX7splK+uEkbBJ5huAhXtLF4Qgl86bCWbEXYzN7rvn0DQfpJAovyFMNRMnfo70XhwqWzFsaYa7Z0YbqYsJE4=
26
+ - secure: l8uznA5K4K9mZ1krmP3lTMD8WcJ32qGxFOR3jubKHcOBSLB4xSzU2aIqjyJdO+rLzebkwamhJc8pGSIWOUDQYvFiX7splK+uEkbBJ5huAhXtLF4Qgl86bCWbEXYzN7rvn0DQfpJAovyFMNRMnfo70XhwqWzFsaYa7Z0YbqYsJE4=
27
+ - JRUBY_OPTS='--dev -X-C -Xcli.debug=true --debug
data/Gemfile CHANGED
@@ -7,17 +7,17 @@ gemspec
7
7
  group :debug do
8
8
  gem 'pry', '~> 0.10.1'
9
9
 
10
- platform :ruby_20, :ruby_21, :ruby_22, :jruby, :rbx do
10
+ if RUBY_VERSION >= '2' && !RUBY_PLATFORM.include?('java')
11
11
  gem 'byebug', '~> 4.0.5'
12
12
  gem 'pry-byebug', '~> 3.1.0'
13
13
  end
14
14
 
15
- platform :ruby_19 do
15
+ if RUBY_VERSION < '2' && !RUBY_PLATFORM.include?('java')
16
16
  gem 'debugger', '~> 1.6.8'
17
17
  gem 'pry-debugger', '~> 0.2.3'
18
18
  end
19
19
 
20
- platform :ruby_19, :ruby_20, :ruby_21, :ruby_22, :jruby, :rbx do
20
+ if RUBY_VERSION >= '1.9.3' && !RUBY_PLATFORM.include?('java')
21
21
  gem 'pry-stack_explorer', '~> 0.4.9'
22
22
  end
23
23
 
@@ -28,7 +28,10 @@ group :development, :test do
28
28
  # Run development tasks
29
29
  gem 'rake', '~> 10.4.2'
30
30
 
31
- platform :ruby_19, :ruby_20, :ruby_21, :ruby_22, :jruby, :rbx do
31
+ if RUBY_VERSION >= '2.0.0'
32
+ # Lint travis yaml
33
+ gem 'travis-yaml'
34
+
32
35
  # Reporting
33
36
  gem 'bcat', '~> 0.6.2'
34
37
  gem 'kramdown', '~> 1.7.0'
@@ -43,27 +46,27 @@ group :development, :test do
43
46
 
44
47
  # using platform for this make bundler complain about the same gem given
45
48
  # twice
46
- if RUBY_VERSION < '1.9'
49
+ if RUBY_VERSION < '1.9.3'
47
50
  gem 'cucumber', '~> 1.3.20'
48
51
  else
49
52
  gem 'cucumber', '~> 2.0'
50
53
  end
51
54
 
52
- # Make aruba compliant to ruby community guide
53
- platform :ruby_19, :ruby_20, :ruby_21, :ruby_22, :jruby, :rbx do
55
+ if RUBY_VERSION >= '1.9.3'
56
+ # Make aruba compliant to ruby community guide
54
57
  gem 'rubocop', '~> 0.32.0'
55
58
  end
56
59
 
57
- platform :ruby_19, :ruby_20, :ruby_21, :ruby_22, :jruby, :rbx do
60
+ if RUBY_VERSION >= '1.9.3'
58
61
  gem 'cucumber-pro', '~> 0.0'
59
62
  end
60
63
 
61
- platform :ruby_19, :ruby_20, :ruby_21, :ruby_22, :jruby, :rbx do
64
+ if RUBY_VERSION >= '1.9.3'
62
65
  # License compliance
63
66
  gem 'license_finder', '~> 2.0.4'
64
67
  end
65
68
 
66
- platform :ruby_19, :ruby_20, :ruby_21, :ruby_22, :jruby, :rbx do
69
+ if RUBY_VERSION >= '1.9.3'
67
70
  # Upload documentation
68
71
  gem 'relish', '~> 0.7.1'
69
72
  end
data/History.md CHANGED
@@ -6,7 +6,10 @@
6
6
  * Re-Add removed method only_processes
7
7
  * Fixed problem with last exit status
8
8
  * Added appveyor to run tests of aruba on Windows (issue #287)
9
- * Added new announcer which outputs full environment before command is run
9
+ * Make the home directory configurable and use Around/around-hook to apply it
10
+ * Add announcer to output the full environment before a command is run
11
+ * Use prepend_environment_variable to modify PATH for rspec integration
12
+ * Add VERSION-constant to aruba and use it for code which should be activated on >= 1.0.0
10
13
 
11
14
  # Old releases
12
15
 
@@ -54,6 +57,9 @@
54
57
  * Better isolation for environment variable manipulation - really helpful from 1.0.0 on
55
58
  * Move configuration files like `jruby.rb` to `aruba/config/`-directory
56
59
  * Change default exit timeout to 15 seconds to work around long running processes on travis
60
+ * Use of instance variables like @aruba_timeout_seconds or
61
+ @aruba_io_wait_seconds are deprecated. Use `Aruba.configure do |config|
62
+ config.exit_timeout = 10` etc. for this.
57
63
 
58
64
  ## [v0.7.4](https://github.com/cucumber/aruba/compare/v0.7.2...v0.7.4)
59
65
  * Really Fixed post install message
@@ -344,15 +350,27 @@
344
350
 
345
351
  # Upcoming un-released versions
346
352
 
347
- ## [v0.9.0](https://github.com/cucumber/aruba/compare/v0.8.0...v0.9.0)
348
- * Make the home directory configurable and use Around/around-hook to apply it
349
- * Add announcer to output the full environment before a command is run
350
- * Use prepend_environment_variable to modify PATH for rspec integration
351
- * Add VERSION-constant to aruba and use it for code which should be activated on >= 1.0.0
353
+ ## [v0.9.0](https://github.com/cucumber/aruba/compare/v0.8.1...v0.9.0)
354
+
355
+ * Improve documentation for filesystem api and move it to feature tests
356
+ * Add logger to aruba. Its output can be captured by rspec.
357
+ * Fix incorrect deprecation message for check_file_presence (issue #292)
358
+ * Fix for Gemfile excludes windows for many gems (issue #282)
359
+ * Make feature tests compatible with ruby 1.9.2
360
+ * Gather disk usage for file(s) (issue #294)
361
+ * Replace keep_ansi-config option by remove_ansi_escape_sequences-option
362
+ * Split up `#unescape` into `#extract_text` and `#unescape_text`
363
+ * Use `UnixPlatform` and `WindowsPlatform` to make code for different platforms maintainable
364
+ * Work around `ENV`-bug in `Jruby` buy using `#dup` on `ENV.to_h` (issue jruby/jruby#3162)
365
+ * Speed up test on `JRuby` by using `--dev`-flag
366
+ * Work around problems when copying files with `cp` on MRI-ruby 1.9.2
367
+ * Add cmd.exe /c for SpawnProcess on Windows (issue #302)
368
+ * Split up `#which` for Windows and Unix/Linux (issue #304)
369
+ * Add `aruba console`-command to play around with aruba (issue 305)
352
370
 
353
371
  ## [v1.0.0](https://github.com/cucumber/aruba/compare/v0.11.0...v1.0.0)
354
372
 
355
- * "ruby 1.8.7"-support is discontinued.
373
+ * Support for rubies older than 1.9.3 is discontinued - e.g 1.8.7 and 1.9.2
356
374
  * aruba requires "cucumber 2" for the feature steps. The rest of aruba should
357
375
  be usable by whatever testing framework you are using.
358
376
  * Overwriting methods for configuration is discontinued. You need to use
data/README.md CHANGED
@@ -1,9 +1,14 @@
1
- [![Build Status](https://travis-ci.org/cucumber/aruba.svg)](http://travis-ci.org/cucumber/aruba)
2
1
  [![Gem Version](https://badge.fury.io/rb/aruba.svg)](http://badge.fury.io/rb/aruba)
3
2
  [![Dependency Status](https://gemnasium.com/cucumber/aruba.svg)](https://gemnasium.com/cucumber/aruba)
4
3
  [![Code Climate](https://codeclimate.com/github/cucumber/aruba.svg)](https://codeclimate.com/github/cucumber/aruba)
5
4
  [![Join the chat at https://gitter.im/cucumber/aruba](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/cucumber/aruba?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
6
5
 
6
+ Build status:
7
+
8
+ Linux / OS X | Windows
9
+ ------------- | -------------
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
+
7
12
  `aruba` is an extension for popular TDD and BDD frameworks like "Cucumber" and "RSpec" to make testing of commandline applications meaningful, easy and fun.
8
13
 
9
14
  Features at a glance:
data/Rakefile CHANGED
@@ -19,11 +19,24 @@ end
19
19
  require 'rspec/core/rake_task'
20
20
  desc "Run RSpec"
21
21
  RSpec::Core::RakeTask.new do |spec|
22
- spec.pattern = 'spec/**/*_spec.rb'
23
22
  spec.rspec_opts = ['--color', '--format documentation']
24
23
  end
25
24
 
26
- if RUBY_VERSION < '1.9'
25
+ namespace :travis do
26
+ desc 'Lint travis.yml'
27
+ task :lint do
28
+ begin
29
+ require 'travis/yaml'
30
+
31
+ puts 'Linting .travis.yml ... No output is good!'
32
+ Travis::Yaml.parse! File.read('.travis.yml')
33
+ rescue LoadError
34
+ $stderr.puts 'You ruby is not supported for linting the .travis.yml'
35
+ end
36
+ end
37
+ end
38
+
39
+ if RUBY_VERSION < '1.9.3'
27
40
  begin
28
41
  require 'rubocop/rake_task'
29
42
  RuboCop::RakeTask.new
@@ -37,6 +50,6 @@ else
37
50
  end
38
51
 
39
52
  desc "Run tests, both RSpec and Cucumber"
40
- task :test => [ :rubocop, :spec, :cucumber, :cucumber_wip]
53
+ task :test => [ 'travis:lint', :rubocop, :spec, :cucumber, :cucumber_wip]
41
54
 
42
55
  task :default => :test
@@ -15,14 +15,21 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.add_runtime_dependency 'cucumber', '>= 1.3.19'
17
17
  s.add_runtime_dependency 'childprocess', '~> 0.5.6'
18
+ s.add_runtime_dependency 'ffi', '~> 1.9.10'
18
19
  s.add_runtime_dependency 'rspec-expectations', '>= 2.99'
19
20
  s.add_runtime_dependency 'contracts', '~> 0.9'
21
+ s.add_runtime_dependency 'thor', '~> 0.19'
20
22
 
21
23
  s.add_development_dependency 'bundler', '~> 1.10.2'
22
24
 
23
25
  s.rubygems_version = ">= 1.6.1"
24
- s.required_ruby_version = '>= 1.8.7'
25
- s.post_install_message = <<-EOS
26
+
27
+ if Aruba::VERSION >= '1'
28
+ s.required_ruby_version = '>= 1.9.3'
29
+ else
30
+ s.required_ruby_version = '>= 1.8.7'
31
+
32
+ s.post_install_message = <<-EOS
26
33
  Use on ruby 1.8.7
27
34
  * Make sure you add something like that to your `Gemfile`. Otherwise you will
28
35
  get cucumber > 2 and this will fail on ruby 1.8.7
@@ -31,6 +38,7 @@ Use on ruby 1.8.7
31
38
 
32
39
  With aruba >= 1.0 there will be breaking changes. Make sure to read https://github.com/cucumber/aruba/blob/master/History.md for 1.0.0
33
40
  EOS
41
+ end
34
42
 
35
43
  s.files = `git ls-files`.split("\n")
36
44
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'aruba/cli'
6
+
7
+ Aruba::Cli.start
@@ -1,9 +1,18 @@
1
1
  <%
2
+ require 'ffi'
2
3
  java_version = (RUBY_DESCRIPTION.match(/.*?on.*?(1\.[\d]\..*? )/))[1] if defined?(JRUBY_VERSION)
3
4
 
4
5
  std_opts = "--color --exclude features/fixtures --require features"
5
6
  java_default_opts = "--tags ~@wip-jruby-java-1.6" if defined?(JRUBY_VERSION) && (java_version < '1.7.0')
6
7
  java_wip_opts = "--tags @wip-jruby-java-1.6:3" if defined?(JRUBY_VERSION) && (java_version < '1.7.0')
8
+
9
+ ignore_opts = []
10
+ ignore_opts << "--tags ~@ignore-platform-java" if RUBY_PLATFORM.include? 'java'
11
+ ignore_opts << "--tags ~@ignore-platform-mri" if !RUBY_PLATFORM.include? 'java'
12
+ ignore_opts << "--tags ~@ignore-platform-windows" if FFI::Platform.windows?
13
+ ignore_opts << "--tags ~@ignore-platform-unix" if FFI::Platform.unix?
14
+ ignore_opts << "--tags ~@ignore-platform-mac" if FFI::Platform.mac?
15
+ ignore_opts = ignore_opts.join(' ')
7
16
  %>
8
- default: <%= std_opts %> --tags ~@wip <%= java_default_opts %>
9
- wip: <%= std_opts %> --wip --tags @wip:3 <%= java_wip_opts %>
17
+ default: <%= std_opts %> --tags ~@wip <%= java_default_opts %> <%= ignore_opts %>
18
+ wip: <%= std_opts %> --wip --tags @wip:3 <%= java_wip_opts %> <%= ignore_opts %>
@@ -0,0 +1,97 @@
1
+ Feature: Extract text from output
2
+
3
+ If you need to strip down some command output to plain text, you can use the
4
+ `#extract_text`-method for this.
5
+
6
+ Background:
7
+ Given I use a fixture named "cli-app"
8
+
9
+ Scenario: Output contains ansi escape codes prefixed by \e
10
+ Given an executable named "bin/cli" with:
11
+ """
12
+ #!/bin/bash
13
+ echo -n "\e[31mText"
14
+ """
15
+ And a file named "spec/which_spec.rb" with:
16
+ """
17
+ require 'spec_helper'
18
+
19
+ RSpec.describe 'Run command', :type => :aruba do
20
+ before(:each) { run('cli') }
21
+ it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" }
22
+ end
23
+ """
24
+ When I run `rspec`
25
+ Then the specs should all pass
26
+
27
+ Scenario: Output contains ansi escape codes prefixed by \033
28
+ Given an executable named "bin/cli" with:
29
+ """
30
+ #!/bin/bash
31
+ echo -n "\033[31mText"
32
+ """
33
+ And a file named "spec/which_spec.rb" with:
34
+ """
35
+ require 'spec_helper'
36
+
37
+ RSpec.describe 'Run command', :type => :aruba do
38
+ before(:each) { run('cli') }
39
+ it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" }
40
+ end
41
+ """
42
+ When I run `rspec`
43
+ Then the specs should all pass
44
+
45
+ # Scenario: Output contains ansi escape codes enclosed by \[\]
46
+ # Given an executable named "bin/cli" with:
47
+ # """
48
+ # #!/bin/bash
49
+ # echo -n "\[\033[31m\]Text"
50
+ # """
51
+ # And a file named "spec/which_spec.rb" with:
52
+ # """
53
+ # require 'spec_helper'
54
+ #
55
+ # RSpec.describe 'Run command', :type => :aruba do
56
+ # before(:each) { run('cli') }
57
+ # it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" }
58
+ # end
59
+ # """
60
+ # When I run `rspec`
61
+ # Then the specs should all pass
62
+
63
+ # Scenario: Output contains ansi escape code \016
64
+ # Given an executable named "bin/cli" with:
65
+ # """
66
+ # #!/bin/bash
67
+ # echo -n "\016Text"
68
+ # """
69
+ # And a file named "spec/which_spec.rb" with:
70
+ # """
71
+ # require 'spec_helper'
72
+ #
73
+ # RSpec.describe 'Run command', :type => :aruba do
74
+ # before(:each) { run('cli') }
75
+ # it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" }
76
+ # end
77
+ # """
78
+ # When I run `rspec`
79
+ # Then the specs should all pass
80
+
81
+ # Scenario: Output contains ansi escape code \017
82
+ # Given an executable named "bin/cli" with:
83
+ # """
84
+ # #!/bin/bash
85
+ # echo -n "\017Text"
86
+ # """
87
+ # And a file named "spec/which_spec.rb" with:
88
+ # """
89
+ # require 'spec_helper'
90
+ #
91
+ # RSpec.describe 'Run command', :type => :aruba do
92
+ # before(:each) { run('cli') }
93
+ # it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" }
94
+ # end
95
+ # """
96
+ # When I run `rspec`
97
+ # Then the specs should all pass
@@ -0,0 +1,119 @@
1
+ Feature: Extract text from output
2
+
3
+ If you need to strip down some command output to plain text, you can use the
4
+ `#unescape_text`-method for this.
5
+
6
+ You may want to have a look
7
+ [here](http://www.unixwerk.eu/unix/ansicodes.html) for a good overview for
8
+ ANSI escape sequences.
9
+
10
+ Background:
11
+ Given I use a fixture named "cli-app"
12
+
13
+ Scenario: Output contains \n
14
+ Given an executable named "bin/cli" with:
15
+ """
16
+ #!/bin/bash
17
+ echo -n 'text\ntext'
18
+ """
19
+ And a file named "spec/which_spec.rb" with:
20
+ """
21
+ require 'spec_helper'
22
+
23
+ RSpec.describe 'Run command', :type => :aruba do
24
+ before(:each) { run('cli') }
25
+ it { expect(unescape_text(last_command.output)).to eq "text\ntext" }
26
+ end
27
+ """
28
+ When I run `rspec`
29
+ Then the specs should all pass
30
+
31
+ Scenario: Output contains \e
32
+ Given an executable named "bin/cli" with:
33
+ """
34
+ #!/bin/bash
35
+ echo -n 'text\etext'
36
+ """
37
+ And a file named "spec/which_spec.rb" with:
38
+ """
39
+ require 'spec_helper'
40
+
41
+ RSpec.describe 'Run command', :type => :aruba do
42
+ before(:each) { run('cli') }
43
+ it { expect(unescape_text(last_command.output)).to eq "texttext" }
44
+ end
45
+ """
46
+ When I run `rspec`
47
+ Then the specs should all pass
48
+
49
+ Scenario: Output contains \"
50
+ Given an executable named "bin/cli" with:
51
+ """
52
+ #!/bin/bash
53
+ echo -n 'text\"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
+ it { expect(unescape_text(last_command.output)).to eq "text\"text" }
62
+ end
63
+ """
64
+ When I run `rspec`
65
+ Then the specs should all pass
66
+
67
+ Scenario: Output contains \033
68
+ Given an executable named "bin/cli" with:
69
+ """
70
+ #!/bin/bash
71
+ echo -n 'text\033text'
72
+ """
73
+ And a file named "spec/which_spec.rb" with:
74
+ """
75
+ require 'spec_helper'
76
+
77
+ RSpec.describe 'Run command', :type => :aruba do
78
+ before(:each) { run('cli') }
79
+ it { expect(unescape_text(last_command.output)).to eq "texttext" }
80
+ end
81
+ """
82
+ When I run `rspec`
83
+ Then the specs should all pass
84
+
85
+ Scenario: Output contains \017
86
+ Given an executable named "bin/cli" with:
87
+ """
88
+ #!/bin/bash
89
+ echo -n 'text\017text'
90
+ """
91
+ And a file named "spec/which_spec.rb" with:
92
+ """
93
+ require 'spec_helper'
94
+
95
+ RSpec.describe 'Run command', :type => :aruba do
96
+ before(:each) { run('cli') }
97
+ it { expect(unescape_text(last_command.output)).to eq "texttext" }
98
+ end
99
+ """
100
+ When I run `rspec`
101
+ Then the specs should all pass
102
+
103
+ Scenario: Output contains \016
104
+ Given an executable named "bin/cli" with:
105
+ """
106
+ #!/bin/bash
107
+ echo -n 'text\016text'
108
+ """
109
+ And a file named "spec/which_spec.rb" with:
110
+ """
111
+ require 'spec_helper'
112
+
113
+ RSpec.describe 'Run command', :type => :aruba do
114
+ before(:each) { run('cli') }
115
+ it { expect(unescape_text(last_command.output)).to eq "texttext" }
116
+ end
117
+ """
118
+ When I run `rspec`
119
+ Then the specs should all pass