pax_global_header00006660000000000000000000000064126725236120014520gustar00rootroot0000000000000052 comment=4d26e4ab3451a4dd852f9c4dadd5da73c9177707 ruby-aruba-0.14.1/000077500000000000000000000000001267252361200136545ustar00rootroot00000000000000ruby-aruba-0.14.1/.document000066400000000000000000000000741267252361200154740ustar00rootroot00000000000000README.rdoc lib/**/*.rb bin/* features/**/*.feature LICENSE ruby-aruba-0.14.1/.gitignore000066400000000000000000000004361267252361200156470ustar00rootroot00000000000000## MAC OS .DS_Store ## TEXTMATE *.tmproj tmtags ## EMACS *~ \#* .\#* ## RUBYMINE .idea ## VIM *.swp tags ## PROJECT::GENERAL coverage rdoc pkg *.log ## PROJECT::SPECIFIC tmp .bundle doc Gemfile.lock cucumber-pro.log ## Ruby versioniser .ruby-version # Temp files of yar .yardoc ruby-aruba-0.14.1/.rspec000066400000000000000000000000471267252361200147720ustar00rootroot00000000000000--color --format Fuubar --order random ruby-aruba-0.14.1/.rubocop.yml000066400000000000000000000073541267252361200161370ustar00rootroot00000000000000AllCops: Exclude: - tmp/**/* DisplayCopNames: true # Cop supports --auto-correct. # Configuration parameters: SupportedStyles. Style/HashSyntax: Enabled: false Metrics/ModuleLength: Exclude: - lib/aruba/api.rb - lib/aruba/api/*.rb - lib/aruba/platform.rb Metrics/AbcSize: Enabled: false Lint/AmbiguousRegexpLiteral: Enabled: false # Cop supports --auto-correct. Lint/RescueException: Enabled: false # Cop supports --auto-correct. Lint/UnusedBlockArgument: Enabled: false # Cop supports --auto-correct. Lint/UnusedMethodArgument: Enabled: false Lint/UselessAssignment: Enabled: false # Configuration parameters: AllowURI. Metrics/LineLength: Max: 169 Exclude: - lib/aruba/api.rb - lib/aruba/api/deprecated.rb - aruba.gemspec # Configuration parameters: CountComments. Metrics/MethodLength: Max: 18 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. Style/AlignParameters: Enabled: false Style/CaseEquality: Enabled: false # Cop supports --auto-correct. Style/CharacterLiteral: Enabled: false # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. Style/ClassCheck: Enabled: false Style/ClassVars: Enabled: false Metrics/ClassLength: Enabled: false # Cop supports --auto-correct. # Configuration parameters: PreferredMethods. Style/CollectionMethods: Enabled: false Style/Documentation: Enabled: false # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: Enabled: false Style/Lambda: Enabled: false # Cop supports --auto-correct. Style/LeadingCommentSpace: Enabled: false # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Enabled: false Metrics/PerceivedComplexity: Enabled: false # Configuration parameters: SupportedStyles. Style/RaiseArgs: # EnforcedStyle: compact Enabled: false # Cop supports --auto-correct. Style/RedundantSelf: Enabled: false # Configuration parameters: MaxSlashes. Style/RegexpLiteral: Enabled: false # Cop supports --auto-correct. # Configuration parameters: AllowAsExpressionSeparator. Style/Semicolon: Enabled: false # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. Style/SignalException: Enabled: false # Configuration parameters: Methods. Style/SingleLineBlockParams: Enabled: false # Cop supports --auto-correct. Style/SpaceBeforeFirstArg: Enabled: false # Cop supports --auto-correct. Style/SpaceAfterComma: Enabled: false # Cop supports --auto-correct. Style/SpaceAroundKeyword: Enabled: false # Cop supports --auto-correct. Style/SpaceAfterNot: Enabled: false # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. Style/SpaceBeforeBlockBraces: Enabled: false # Cop supports --auto-correct. Style/SpaceBeforeComma: Enabled: false # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. Style/SpaceInsideBlockBraces: Enabled: false # Cop supports --auto-correct. Style/SpaceInsideBrackets: Enabled: false # Cop supports --auto-correct. Style/SpaceInsideParens: Enabled: false # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. Style/StringLiterals: Enabled: false # Cop supports --auto-correct. # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist. Style/TrivialAccessors: Enabled: false Style/RaiseArgs: Enabled: false Metrics/ParameterLists: Enabled: false Style/IfInsideElse: Enabled: false Style/IdenticalConditionalBranches: Enabled: false ruby-aruba-0.14.1/.simplecov000066400000000000000000000017641267252361200156660ustar00rootroot00000000000000# Run simplecov by default SimpleCov.start unless ENV.key? 'ARUBA_NO_COVERAGE' SimpleCov.configure do # ignore this file add_filter '.simplecov' add_filter 'spec' add_filter 'features' # Rake tasks aren't tested with rspec add_filter 'Rakefile' add_filter 'lib/tasks' # # Changed Files in Git Group # @see http://fredwu.me/post/35625566267/simplecov-test-coverage-for-changed-files-only untracked = `git ls-files --exclude-standard --others` unstaged = `git diff --name-only` staged = `git diff --name-only --cached` all = untracked + unstaged + staged changed_filenames = all.split("\n") add_group 'Changed' do |source_file| changed_filenames.select do |changed_filename| source_file.filename.end_with?(changed_filename) end end add_group 'Libraries', 'lib' # Specs are reported on to ensure that all examples are being run and all # lets, befores, afters, etc are being used. add_group 'Specs', 'spec' end ruby-aruba-0.14.1/.travis.yml000066400000000000000000000020151267252361200157630ustar00rootroot00000000000000sudo: false language: ruby script: script/test install: script/bootstrap --without development debug rvm: - 1.8.7 - 1.9.2 - 1.9.3 - 2.0.0 - 2.1.8 - 2.2.4 - 2.3.0 - jruby - jruby-20mode - jruby-21mode - rbx matrix: include: - rvm: jruby-9.0.1.0 env: JRUBY_OPTS='--dev' - rvm: jruby-9.0.1.0-20mode env: JRUBY_OPTS='--dev' - rvm: jruby-9.0.1.0-21mode env: JRUBY_OPTS='--dev' allow_failures: - rvm: rbx - rvm: jruby-9.0.1.0 env: JRUBY_OPTS='--dev' - rvm: jruby-9.0.1.0-20mode env: JRUBY_OPTS='--dev' - rvm: jruby-9.0.1.0-21mode env: JRUBY_OPTS='--dev' notifications: email: - cukes-devs@googlegroups.com webhooks: urls: - https://webhooks.gitter.im/e/d4d9080e2a8c4910f609 env: global: - secure: l8uznA5K4K9mZ1krmP3lTMD8WcJ32qGxFOR3jubKHcOBSLB4xSzU2aIqjyJdO+rLzebkwamhJc8pGSIWOUDQYvFiX7splK+uEkbBJ5huAhXtLF4Qgl86bCWbEXYzN7rvn0DQfpJAovyFMNRMnfo70XhwqWzFsaYa7Z0YbqYsJE4= - JRUBY_OPTS='--dev' cache: apt addons: apt: packages: - zsh ruby-aruba-0.14.1/.yardopts000066400000000000000000000001611267252361200155200ustar00rootroot00000000000000--output doc/yard --exclude features/ --verbose --markup-provider kramdown --markup markdown - LICENSE README.md ruby-aruba-0.14.1/CONTRIBUTING.md000066400000000000000000000062721267252361200161140ustar00rootroot00000000000000## About to create a new Github Issue? We appreciate that. But before you do, please learn our basic rules: * This is not a support forum. If you have a question, please go to [The Cukes Google Group](http://groups.google.com/group/cukes). * Do you have an idea for a new feature? Then don't expect it to be implemented unless you or someone else sends a [pull request](https://help.github.com/articles/using-pull-requests). You might be better to start a discussion on [the google group](http://groups.google.com/group/cukes). * Reporting a bug? Please tell us: * which version of Aruba you're using * which version of Ruby you're using. * How to reproduce it. Bugs with a failing test in a [pull request](https://help.github.com/articles/using-pull-requests) get fixed much quicker. Some bugs may never be fixed. * Want to paste some code or output? Put \`\`\` on a line above and below your code/output. See [GFM](https://help.github.com/articles/github-flavored-markdown)'s *Fenced Code Blocks* for details. * We love [pull requests](https://help.github.com/articles/using-pull-requests). But if you don't have a test to go with it we probably won't merge it. # Contributing to Aruba This document is a guide for those maintaining Aruba, and others who would like to submit patches. ## Note on Patches/Pull Requests * Fork the project. Make a branch for your change. * Make your feature addition or bug fix. * Make sure your patch is well covered by tests. We don't accept changes that aren't tested. * Please do not change the Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself so we can ignore when we merge your change) * Send us a pull request. ## Bootstrap environment To get started with `aruba`, you just need to bootstrap the environment by running the following command. # Bootstrap environment script/bootstrap ## Running tests Make sure you bootstrap the environment first. # Run the test suite script/test ## Release Process * Bump the version number in `aruba.gemspec` * Make sure `History.md` is updated with the upcoming version number, and has entries for all fixes. * No need to add a `History.md` header at this point - this should be done when a new change is made, later. Now release it bundle update bundle exec rake git commit -m "Release X.Y.Z" rake release Now email cukes@googlegroups.com with details of the new release. Just a copy / paste from the History.md file is normally fine. ## Gaining Release Karma To become a release manager, create a pull request adding your name to the list below, and include your Rubygems email address in the ticket. One of the existing Release managers will then add you. Current release managers: * Jarl Friis ([@jarl-dk](https://github.com/jarl-dk)) * Matt Wynne ([@mattwynne](http://github.com/mattwynne)) * Aslak Hellesøy ([@aslakhellesoy](http://github.com/aslakhellesoy)) * Tom Brand ([@tom025](https://github.com/tom025)) * Dennis Günnewig ([@maxmeyer](http://github.com/maxmeyer), [@dg-rationdata](http://github.com/dg-rationdata)) To grant release karma, issue the following command: gem owner aruba --add ruby-aruba-0.14.1/Gemfile000066400000000000000000000031221267252361200151450ustar00rootroot00000000000000source 'https://rubygems.org' # Use dependencies from gemspec gemspec # Debug aruba group :debug do if RUBY_VERSION >= '2' && !RUBY_PLATFORM.include?('java') gem 'byebug', '~> 4.0.5' gem 'pry-byebug', '~> 3.1.0' end if RUBY_VERSION < '2' && RUBY_VERSION > '1.9' && !RUBY_PLATFORM.include?('java') gem 'debugger', '~> 1.6.8' gem 'pry-debugger', '~> 0.2.3' end gem 'pry-doc', '~> 0.8.0' end group :development, :test do # we use this to demonstrate interactive debugging within our feature tests if RUBY_VERSION >= '2' gem 'pry', '~> 0.10.1' else gem 'pry', '~>0.9.12' end # Run development tasks gem 'rake', '~> 10.4.2' if RUBY_VERSION >= '2.0.0' # Lint travis yaml gem 'travis-yaml' # Reporting gem 'bcat', '~> 0.6.2' gem 'kramdown', '~> 1.7.0' end # Code Coverage gem 'simplecov', '~> 0.10' # Test api gem 'rspec', '~> 3.4' gem 'fuubar', '~> 2.0.0' # using platform for this make bundler complain about the same gem given # twice if RUBY_VERSION < '1.9.3' gem 'cucumber', '~> 1.3.20' else gem 'cucumber', '~> 2.0' end if RUBY_VERSION >= '1.9.3' # Make aruba compliant to ruby community guide gem 'rubocop', '~> 0.32' end if RUBY_VERSION >= '1.9.3' gem 'cucumber-pro', '~> 0.0' end if RUBY_VERSION >= '1.9.3' # License compliance gem 'license_finder', '~> 2.0.4' end if RUBY_VERSION >= '1.9.3' # Upload documentation gem 'relish', '~> 0.7.1' end gem 'minitest', '~> 5.8.0' end platforms :rbx do gem 'rubysl', '~> 2.0' gem 'rubinius-developer_tools' end ruby-aruba-0.14.1/History.md000066400000000000000000000652561267252361200156550ustar00rootroot00000000000000# UNRELEASED ## [v1.0.0](https://github.com/cucumber/aruba/compare/v0.11.0...v1.0.0) * Support for rubies older than 1.9.3 is discontinued - e.g 1.8.7 and 1.9.2 * aruba requires "cucumber 2" for the feature steps. The rest of aruba should be usable by whatever testing framework you are using. * Overwriting methods for configuration is discontinued. You need to use `aruba.config.` or `Aruba.configure { |config| config.` instead. * "aruba/reporting" will be removed. Please use `@debug`-tag + `byebug`, `debugger`, `pry` to troubleshoot your feature tests. * Set environment variables will have only effect on `#run` and the like + `#with_environment { }`. * The process environment will be fully resetted between tests. Sharing state via ENV['VAR'] = 'shared state' between tests will not be possible anymore. Please make that obvious by using explicit steps or use the aruba API for that. * There will be a major cleanup for command execution. There will be only `run` and `run_simple` left. `run_interactive` is replaced by `run`. * Setting the root directory of aruba via method overwrite or configuration - this should be your project root directory where the test suite is run. * The direct use of "InProcess", "DebugProcess" and "SpawnProcess" is not supported anymore. You need to use "Command" instead. But be careful, it has a different API. * HOME can be configured via `Aruba.configure {}` and defaults to `File.join(aruba.config.root_directory, aruba.config.working_directory?)` if `aruba/cucumber` or `aruba/rspec` is used. * Use different working directories based on test suite - RSpec, Cucumber. It's `tmp/rspec` and `tmp/cucumber` now to make sure they do not overwrite the test results from each other. * The use of `@interactive` is discontinued. You need to use `#last_command_started`-method to get access to the interactively started command. * If multiple commands have been started, each output has to be check separately ```cucumber Scenario: Detect stdout from all processes When I run `printf "hello world!\n"` And I run `cat` interactively And I type "hola" And I type "" Then the stdout should contain: """ hello world! """ And the stdout should contain: """ hola """ And the stderr should not contain anything ``` # RELEASED ## [v0.14.1](https://github.com/cucumber/aruba/compare/v0.14.0...v0.14.1) * Fixed bug in framework step ## [v0.14.0](https://github.com/cucumber/aruba/compare/v0.13.0...v0.14.0) * Add `/exe` to search path for commands: This is the new default if you setup a project with bundler. * Add some more steps to modify environment ## [v0.13.0](https://github.com/cucumber/aruba/compare/v0.12.0...v0.13.0) * Add two new hooks for rspec and cucumber to make troubleshooting feature files easier (PR #338): * command_content: Outputs command content - helpful for scripts * command_filesystem_status: Outputs information like group, owner, mode, atime, mtime * Add generator to create ad hoc script file (PR #323, @AdrieanKhisbe) * Colored announcer output similar to the color of `cucumber` tags: cyan * Fixed bug in announcer. It announces infomation several times due to duplicate announce-calls. * Refactorings to internal `#simple_table`-method (internal) * Refactored Announcer, now it supports blocks for announce as well (internal) * Fix circular require warnings (issue #339) * Fix use of old instances variable "@io_wait" (issue #341). Now the default value for io_wait_timeout can be set correctly. * Make it possible to announce information on command error, using a new option called `activate_announcer_on_command_failure` (PR #335, @njam) * Re-integrate `event-bus`-library into `aruba`-core (PR #342) ## [v0.12.0](https://github.com/cucumber/aruba/compare/v0.11.2...v0.12.0) * Add matcher to check if a command can be found in PATH (PR #336) * Fixed issue with environment variables set by external libraries (fix #321, issue #320) # Old releases ## [v0.11.2](https://github.com/cucumber/aruba/compare/v0.11.1...v0.11.2) * Fixed problem with positional arguments in `#run_simple()` (issue #322) ## [v0.11.1](https://github.com/cucumber/aruba/compare/v0.11.0...v0.11.1) * Use fixed version of event-bus * Refactored and improved documentation (feature tests) in PR #309 ## [v0.11.0](https://github.com/cucumber/aruba/compare/v0.11.0.pre4...v0.11.0) * Accidently pushed to rubygems.org - yanked it afterwards ## [v0.11.0.pre4](https://github.com/cucumber/aruba/compare/v0.11.0.pre3...v0.11.0.pre4) * Fixed syntax for Hash on ruby 1.8.7 * Reorder rubies in .travis.yml ## [v0.11.0.pre3](https://github.com/cucumber/aruba/compare/v0.11.0.pre2...v0.11.0.pre3) * Fixed syntax for proc on ruby 1.8.7 ## [v0.11.0.pre2](https://github.com/cucumber/aruba/compare/v0.11.0.pre...v0.11.0.pre2) * Integrate `EventBus` to decouple announcers from starting, stopping commands etc. This uses nearly the same implementation like `cucumber`. (PR #309) * Starting/Stopping a command directly (`command.start`, `command.stop`) is now reported to the command monitor and `last_command_stopped` is updated correctly * Added `#restart` to `Command` to make it possible to restart a command * Added check to prevent a command which has already been started, to be started again. Otherwise you've got hidden commands which are not stopped after a cucumber/rspec/minitest run. * Adding alot of documentation to `aruba` * Refactored `#run`: Now it wants you to pass a `Hash` containing the options. The old syntax is still supported, but is deprecated. * Added `#find_command` as experimental feature. It searches the started commands from last to first. * Added `be_an_executable` matcher ## [v0.11.0.pre](https://github.com/cucumber/aruba/compare/v0.10.2...v0.11.0.pre) * Set stop signal which should be used to stop a process after a timeout or used to terminate a process. This can be used to stop processes running docker + "systemd". If you send a systemd-enable container SIGINT it will be stopped. * Added a configurable amount of time after a command was started - startup_wait_time. Otherwise you get problems when a process takes to long to startup when you run in background and want to sent it a signal. * Replace `` in commandline, e.g. `` [experimental] * Added announce formatter for time spans, e.g. `startup_wait_time` * All `*Process`-classes e.g. `BasicProcess`, `SpawnProcess` etc. are marked as private. Users should use `#run('cmd')` and don't use the classes directly. * `rvm`-methods are deprecated. They too ruby specific. ## [v0.10.2](https://github.com/cucumber/aruba/compare/v0.10.1...v0.10.2) * Fixed problem in regex after merge of step definitions ## [v0.10.1](https://github.com/cucumber/aruba/compare/v0.10.0...v0.10.1) * Merged remove steps for file and directory from 4 into 2 step definitions ## [v0.10.0](https://github.com/cucumber/aruba/compare/v0.10.0.pre2...v0.10.0) * Fix '"#exit_timeout" is deprecated' error (issue #314) ## [v0.10.0.pre2](https://github.com/cucumber/aruba/compare/v0.10.0.pre...v0.10.0.pre2) * Take over code from `RSpec::Support::ObjectFormatter` since `rspec-support` is not intended for public use. ## [v0.10.0.pre](https://github.com/cucumber/aruba/compare/v0.9.0...v0.10.0) * Add some new steps to make writing documentation easier using "cucumber", "rspec", "minitest" together with "aruba" - see [Feature](features/getting_started/supported_testing_frameworks.feature) for some examples * Write output of commands directly to disk if SpawnProcess is used (see https://github.com/cucumber/aruba/commit/85d74fcca4fff4e753776925d8b003cddaa8041d) * Refactored API of cucumber steps to reduce the need for more methods and make it easier for users to write their own steps (issue #306) * Added `aruba init` to the cli command to setup environment for aruba (issue #308) * Added new method `delete_environment_variable` to remove environment variable * Added work around because of method name conflict between Capybara and RSpec (https://github.com/cucumber/aruba/commit/1939c4049d5195ffdd967485f50119bdd86e98a0) ## [v0.9.0](https://github.com/cucumber/aruba/compare/v0.9.0.pre2...v0.9.0) * Fix feature test * Fix ordering in console * Fix bug in console handling SIGINT * Deprecated Aruba/Reporting before we remove it ## [v0.9.0.pre2](https://github.com/cucumber/aruba/compare/v0.9.0.pre...v0.9.0.pre2) * Redefine #to_s and #inspect for BasicProcess to reduce the sheer amount of information, if a command produces a lot of output * Added new matcher `#all_objects` to check if an object is included + a error message for failures which is similar to the `#all`-matcher of `RSpec` * Add `have_output`-, `have_output_on_stderr`, `have_output_on_stdout`-matchers * Replace all `assert_*` and `check_*`-methods through expectations * Add hook `@announce-output` to output both, stderr and stdout * Add a lot of documentation (issue #260) * Replace `#last_command` through `#last_command_started` and `#last_command_stopped` to make it more explicit * Improve syntax highlighting in cucumber feature tests by adding programming language to `"""`-blocks * Rename tags `@ignore-*` to `@unsupported-on-*` * Introduce our own `BaseMatcher`-class to remove the dependency to `RSpec`'s private matcher APIs * Now we make the process started via `SpawnProcess` the leader of the group to kill all sub-processes more reliably ## [v0.9.0.pre](https://github.com/cucumber/aruba/compare/v0.8.1...v0.9.0.pre) * Improve documentation for filesystem api and move it to feature tests * Add logger to aruba. Its output can be captured by rspec. * Fix incorrect deprecation message for check_file_presence (issue #292) * Fix for Gemfile excludes windows for many gems (issue #282) * Make feature tests compatible with ruby 1.9.2 * Gather disk usage for file(s) (issue #294) * Replace keep_ansi-config option by remove_ansi_escape_sequences-option * Split up `#unescape` into `#extract_text` and `#unescape_text` * Use `UnixPlatform` and `WindowsPlatform` to make code for different platforms maintainable * Work around `ENV`-bug in `Jruby` buy using `#dup` on `ENV.to_h` (issue jruby/jruby#3162) * Speed up test on `JRuby` by using `--dev`-flag * Work around problems when copying files with `cp` on MRI-ruby 1.9.2 * Add cmd.exe /c for SpawnProcess on Windows (issue #302) * Split up `#which` for Windows and Unix/Linux (issue #304) * Add `aruba console`-command to play around with aruba (issue 305) ## [v0.8.1](https://github.com/cucumber/aruba/compare/v0.8.0...v0.8.1) * Fix problem if working directory of aruba does not exist (issue #286) * Re-Add removed method only_processes * Fixed problem with last exit status * Added appveyor to run tests of aruba on Windows (issue #287) * Make the home directory configurable and use Around/around-hook to apply it * Add announcer to output the full environment before a command is run * Use prepend_environment_variable to modify PATH for rspec integration * Add VERSION-constant to aruba and use it for code which should be activated on >= 1.0.0 ## [v0.8.0](https://github.com/cucumber/aruba/compare/v0.8.0.pre3...v0.8.0) * Build with cucumber 1.3.x on ruby 1.8.7, with cucumber 2.x on all other platforms * Fixed bugs in aruba's cucumber steps * Disable use of `win32/file` * Fixed but in `in_current_dir*` not returning the result of the block * Fixed checks for file content * Fixed selectors for DebugProcess and InProcess to support sub-classes as well ## [v0.8.0.pre3](https://github.com/cucumber/aruba/compare/v0.8.0.pre2...v0.8.0.pre3) * Depend on cucumber 1.3.x for compatibility on ruby 1.8.7 * Change PWD and OLDPW when `cd('path') {}` is used within that block * Make nesting of `cd` possible * Make `run` inside `cd` possible * Fixed some bugs * Move `Aruba.proces = InProcess|SpawnProcess|DebugProcess` to `aruba.config` * Deprecate direct use of `InProcess|SpawnProcess|DebugProcess`. Now `Command` needs to be used * Add new configuration options `command_launcher` and `main_klass` for deprecation of old-style `Aruba.process = `, `:spawn` is the default value for the `command_launcher`-option * Added checks for version of `rspec-expectations` to support older `rspec` versions like `2.11` * Now each `path/to/dir` pushed to `aruba.current_directory` is `pop`ed as whole * Make testing of `aruba.current_directory` easier by supporting `end_with?` and `start_with?` ## [v0.8.0.pre2](https://github.com/cucumber/aruba/compare/v0.8.0...v0.8.0.pre2) * Relax requirement on rspec-expectations (3.3 -> 2.11) ## [v0.8.0.pre](https://github.com/cucumber/aruba/compare/v0.7.4...v0.8.0.pre) * Make aruba compatible with "ruby 1.8.7" and "ruby 1.9.3" again (fixes #279) * Move more and more documentation to cucumber steps (partly fixes #268) * Refactoring of test suits, now rspec tests run randomly * Move Aruba constants to configuration class (fixes #271) * Added runtime configuration via `aruba.config` which is reset for each test run * Refactored hooks: now there are `after()` and `before()`-hooks, old before_cmd-hook is still working, but is deprecated, added new `after(:command)`-hook. * Refactored jruby-startup helper * Cleanup API by moving deprecated methods to separate class * Cleanup Core API - reduced to `cd`, `expand_path`, `setup_aruba` and use expand_path wherever possible (fixes #253) * Better isolation for environment variable manipulation - really helpful from 1.0.0 on * Move configuration files like `jruby.rb` to `aruba/config/`-directory * Change default exit timeout to 15 seconds to work around long running processes on travis * Use of instance variables like @aruba_timeout_seconds or @aruba_io_wait_seconds are deprecated. Use `Aruba.configure do |config| config.exit_timeout = 10` etc. for this. ## [v0.7.4](https://github.com/cucumber/aruba/compare/v0.7.2...v0.7.4) * Really Fixed post install message ## [v0.7.3](https://github.com/cucumber/aruba/compare/v0.7.2...v0.7.3) * Fixed post install message ## [v0.7.2](https://github.com/cucumber/aruba/compare/v0.7.1...v0.7.2) * Do not trigger Announcer API deprecation warning (issue #277) ## [v0.7.1](https://github.com/cucumber/aruba/compare/v0.7.0...v0.7.1) * Do not break if @interactive is used ## [v0.7.0](https://github.com/cucumber/aruba/compare/v0.6.2...v0.7.0) * Introducing root_directory (issue #232) * Introducing fixtures directory (issue #224) * Make sure a file/directory does not exist + Cleanup named file/directory steps (issue #234) * Make matcher have_permisions public and add documentation (issue #239) * Added matcher for file content (issue #238) * Add rspec integrator (issue #244) * Deprecate _file/_directory in method names (issue #243) * Improve development environment (issue #240) * Cleanup process management (issue #257) * Make path content available through matchers and api metchods (issue #250) * Refactor announcer to support user defined announce channels (fixes #267) * `InProcess` requires that the working directory is determined on runtime not no loadtime ## [v0.6.2](https://github.com/cucumber/aruba/compare/v0.6.1...v0.6.2) * Fixed minor issue #223) * Added support for ruby 2.1.3 -- 2.1.5 * Added support for comparison to a fixture file ## [v0.6.1](https://github.com/cucumber/aruba/compare/v0.6.0...v0.6.1) * Added support for ruby 2.1.2 * Added support for ~ expansion * Added support for with_env ## [v0.6.0](https://github.com/cucumber/aruba/compare/v0.5.4...v0.6.0) * Dropped support for ruby 1.8 * Added support for ruby 2.1.0 and 2.1.1 * Added rspec 3.0.0 support ## [v0.5.4](https://github.com/cucumber/aruba/compare/v0.5.3...v0.5.4) * Added support for piping in files (#154 maxmeyer, dg-vrnetze) * Added cucumber steps for environment variables (#156 dg-vrnetze) * Added support for file mode (#157 maxmeyer, dg-vrnetze) ## [v0.5.3](https://github.com/cucumber/aruba/compare/v0.5.2...v0.5.3) * Fix for UTF-8 support (#151 Matt Wynne, Jarl Friis) * Fix for open file leakage (#150 @JonRowe) ## [v0.5.2](https://github.com/cucumber/aruba/compare/v0.5.1...v0.5.2) * Plugin API for greater speed. Test Ruby CLI programs in a single Ruby process (#148 Aslak Hellesøy) * Fix memory leak when several commands are executed in a single run (#144 @y-higuchi) ## [v0.5.1](https://github.com/cucumber/aruba/compare/v0.5.0...v0.5.1) * Individual timeout settings when running commands (#124 Jarl Friis) * Varous fixes for JRuby tests, should now work on more versions of JRuby ## [v0.5.0](https://github.com/cucumber/aruba/compare/v0.4.10...v0.5.0) * Add #with_file_content to the DSL (#110 Pavel Argentov) * Make JRuby performance tweaks optional (#102 Taylor Carpenter, #125 Andy Lindeman) * Add assert_partial_output_interactive so you can peek at the output from a running process (#104 Taylor Carpenter) * Add assert_not_matching_output (#111 Pavel Argentov) * Add remove_dir (#121 Piotr Niełacny) ## [v0.4.11](https://github.com/cucumber/aruba/compare/v0.4.10...v0.4.11) * Fix duplicated output (#91 Robert Wahler, Matt Wynne) * Fix Gemspec format (#101 Matt Wynne) ## [v0.4.10](https://github.com/cucumber/aruba/compare/v0.4.9...v0.4.10) * Fix broken JRuby file following rename of hook (Thomas Reynolds) * Add terminate method to API (Taylor Carpenter) ## [v0.4.9](https://github.com/cucumber/aruba/compare/v0.4.8...v0.4.9) * Rename before_run hook to before_cmd (Matt Wynne) * Fix 1.8.7 compatibility (#95 Dave Copeland) ## [v0.4.8](https://github.com/cucumber/aruba/compare/v0.4.7...v0.4.8) * Add before_run hook (Matt Wynne) * Add JRuby performance tweaks (#93 Myron Marston / Matt Wynne) * Invalid/Corrupt spec file for 0.4.7 - undefined method call for nil:Nilclass (#47 Aslak Hellesøy) ## [v0.4.7](https://github.com/cucumber/aruba/compare/v0.4.6...v0.4.7) * Remove rdiscount dependency. (#85 Aslak Hellesøy) * Pin to ffi 1.0.9 since 1.0.10 is broken. (Aslak Hellesøy) * Added file size specific steps to the Aruba API. (#89 Hector Castro) ## [v0.4.6](https://github.com/cucumber/aruba/compare/v0.4.5...v0.4.6) * Upgraded deps to latest gems. (Aslak Hellesøy) * Added Regexp support to Aruba::Api#assert_no_partial_output (Aslak Hellesøy) ## [v0.4.5](https://github.com/cucumber/aruba/compare/v0.4.4...v0.4.5) * Better assertion failure message when an exit code is not as expected. (Matt Wynne) ## [v0.4.4](https://github.com/cucumber/aruba/compare/v0.4.3...v0.4.4) * Fix various bugs with interative processes. (Matt Wynne) ## [v0.4.3](https://github.com/cucumber/aruba/compare/v0.4.2...v0.4.3) * Aruba reporting now creates an index file for reports, linking them all together. (Aslak Hellesøy) ## [v0.4.2](https://github.com/cucumber/aruba/compare/v0.4.1...v0.4.2) * Appending to a file creates the parent directory if it doesn't exist. (Aslak Hellesøy) ## [v0.4.1](https://github.com/cucumber/aruba/compare/v0.4.0...v0.4.1) * Move more logic into Aruba::Api (Aslak Hellesøy) ## [v0.4.0](https://github.com/cucumber/aruba/compare/v0.3.7...v0.4.0) * New, awesome HTML reporting feature that captures everything that happens during a scenario. (Aslak Hellesøy) * ANSI escapes from output are stripped by default. Override this with the @ansi tag. (Aslak Hellesøy) ## [v0.3.7](https://github.com/cucumber/aruba/compare/v0.3.6...v0.3.7) * Make Aruba::Api#get_process return the last executed process with passed cmd (Potapov Sergey) * Replace announce with puts to comply with cucumber 0.10.6 (Aslak Hellesøy) * Fix childprocess STDIN to be synchronous (#40, #71 Tim Ekl) ## [v0.3.6](https://github.com/cucumber/aruba/compare/v0.3.5...v0.3.6) * Changed default value of @aruba_timeout_seconds from 1 to 3. (Aslak Hellesøy) * Separate hooks and steps to make it easier to build your own steps on top of Aruba's API (Mike Sassak) * @no-clobber to prevent cleanup before each scenario (Mike Sassak) ## [v0.3.5](https://github.com/cucumber/aruba/compare/v0.3.4...v0.3.5) * Store processes in an array to ensure order of operations on Ruby 1.8.x (#48 Mike Sassak) ## [v0.3.4](https://github.com/cucumber/aruba/compare/v0.3.3...v0.3.4) * Use backticks (\`) instead of quotes (") to specify command line. Quote still works, but is deprecated. (Anthony Eden, Aslak Hellesøy) ## [v0.3.3](https://github.com/cucumber/aruba/compare/v0.3.2...v0.3.3) * Updated RSpec development requirement to 2.5 (Robert Speicher, Mike Sassak, Aslak Hellesøy) * Updated RubyGems dependency to 1.6.1 (Robert Speicher) ## [v0.3.2](https://github.com/cucumber/aruba/compare/v0.3.1...v0.3.2) * Wrong number of args in the When I overwrite step (Aslak Hellesøy) ## [v0.3.1](https://github.com/cucumber/aruba/compare/v0.3.0...v0.3.1) * Broken 0.3.0 release (#43, #44 Mike Sassak) * Quotes (") and newline (\n) in step arguments are no longer unescaped. (Aslak Hellesøy) ## [v0.3.0](https://github.com/cucumber/aruba/compare/v0.2.8...v0.3.0) * Remove latency introduced in the 0.2.8 release (#42 Mike Sassak) * New stepdef Then /^the stdout should contain:$/ do |partial_output| (Aslak Hellesøy) * Quotes (") and newline (\n) in step arguments no longer need to be backslash-escaped. (Aslak Hellesøy) ## [v0.2.8](https://github.com/cucumber/aruba/compare/v0.2.7...v0.2.8) * Replaced background_process with childprocess, a cross-platform process control library. This will allow Aruba to run on Windows and JRuby in addition to *nix MRI. (#16, #27, #31 Mike Sassak, Jari Bakken, Matt Wynne, Arve Knudsen) ## [v0.2.7](https://github.com/cucumber/aruba/compare/v0.2.6...v0.2.7) * Upgrade to Cucumber 0.10.0. (Aslak Hellesøy) * require 'aruba' does nothing - you have to require 'aruba/cucumber' now. This is to prevent bundler from loading it when we don't want to. (Aslak Hellesøy) * Outputting a lot of data causes process to time out (#30 Mike Sassak) ## [v0.2.6](https://github.com/cucumber/aruba/compare/v0.2.5...v0.2.6) * You can set @aruba_timeout_seconds in a Before hook to tell Aruba to wait for a process to complete. Default: 1 second. (Aslak Hellesøy) * Fixed small bug in /^the stdout should contain exactly:$/ (Aslak Hellesøy) ## [v0.2.5](https://github.com/cucumber/aruba/compare/v0.2.4...v0.2.5) * Added 'a file named "whatever" should (not) exist' (Robert Speicher) * Added 'a directory named "whatever" should (not) exist' (Robert Speicher) * Added /^the stderr should contain exactly:"$/ (Aslak Hellesøy) * Added /^the stdout should contain exactly:"$/ (Aslak Hellesøy) * Added /it should pass with exactly:/ (Aslak Hellesøy) * @announce, @announce-dir and @announce-cmd for interactive processes (Mike Sassak) * Add step defs for detecting output, stdout and stderr by process name (Mike Sassak) * Stop all processes before verifying filesystem changes to ensure async operations are complete (#17 Mike Sassak) * Outputting large amounts of data causes run steps to hang (#18 Mike Sassak) ## [v0.2.4](https://github.com/cucumber/aruba/compare/v0.2.3...v0.2.4) * Added step definitions for removing files and checking presence of a single file. (Aslak Hellesøy) ## [v0.2.3](https://github.com/cucumber/aruba/compare/v0.2.2...v0.2.3) * Directory should not exist gives false-positive (#13,#15 Nicholas Rutherford) * Added step definitions for comparing file contents with regexps (#9 Aslak Hellesøy) * Always put ./bin at the beginning of $PATH to make it easier to run own executables (#7 Aslak Hellesøy) * Communication with interactive processes (#4 Mike Sassak) * Remove hyphens separating stdout and stderr (Arve Knudsen) ## [v0.2.2](https://github.com/cucumber/aruba/compare/v0.2.1...v0.2.2) * Added a @bin tag that sets up './bin' first on the path (Aslak Hellesøy) * Richer API making aruba easier to use from Ruby code. (Mark Nijhof, Aslak Hellesøy) * No more support for RVM. Use rvm 1.9.2,1.8.7 exec cucumber .... instead. (Mark Nijhof, Aslak Hellesøy) ## [v0.2.1](https://github.com/cucumber/aruba/compare/v0.2.0...v0.2.1) * Always compare with RSpec should =~ instead of should match. This gives a diff when there is no match. (Aslak Hellesøy) ## [v0.2.0](https://github.com/cucumber/aruba/compare/v0.1.9...v0.2.0) * Added aruba.gemspec. (David Chelimsky) * Several step definitions regarding output have changed. (#1 Aslak Hellesøy) - /^I should see "([^\"]*)"$/ + /^the output should contain "([^"]*)"$/ - /^I should not see "([^\"]*)"$/ + /^the output should not contain "([^"]*)"$/ - /^I should see:$/ + /^the output should contain:$/ - /^I should not see:$/ + /^the output should not contain:$/ - /^I should see exactly "([^\"]*)"$/ + /^the output should contain exactly "([^"]*)"$/ - /^I should see exactly:$/ + /^the output should contain exactly:$/ - /^I should see matching \/([^\/]*)\/$/ + /^the output should match \/([^\/]*)\/$/ - /^I should see matching:$/ + /^the output should match:$/ ## [v0.1.9](https://github.com/cucumber/aruba/compare/v0.1.8...v0.1.9) * If the GOTGEMS environment variable is set, bundler won't run (faster). (Aslak Hellesøy) ## [v0.1.8](https://github.com/cucumber/aruba/compare/v0.1.7...v0.1.8) * Use // instead of "" for "I should see matching" step. (Aslak Hellesøy) * Replace rvm gemset character '%' with '@' for rvm 0.1.24 (#5 Ashley Moran) * Support gem bundler, making it easier to specify gems. (Aslak Hellesøy) ## [v0.1.7](https://github.com/cucumber/aruba/compare/v0.1.6...v0.1.7) * New @announce-stderr tag (Robert Wahler) * New "I should see matching" steps using Regexp (Robert Wahler) ## [v0.1.6](https://github.com/cucumber/aruba/compare/v0.1.5...v0.1.6) * When /^I successfully run "(.*)"$/ now prints the combined output if exit status is not 0. (Aslak Hellesøy) * Add bundle to list of common ruby scripts. (Aslak Hellesøy) ## [v0.1.5](https://github.com/cucumber/aruba/compare/v0.1.4...v0.1.5) * Added ability to map rvm versions to a specific version with config/aruba-rvm.yml. (Aslak Hellesøy) * Check for presence of files. (Aslak Hellesøy) * Allow specification of rvm gemsets. (Aslak Hellesøy) * Detect ruby commands and use current ruby when rvm is not explicitly used. (Aslak Hellesøy) * Added support for rvm, making it possible to choose Ruby interpreter. (Aslak Hellesøy) * Added @announce-cmd, @announce-stdout and @announce tags, useful for seeing what's executed and outputted. (Aslak Hellesøy) ## [v0.1.4](https://github.com/cucumber/aruba/compare/v0.1.3...v0.1.4) * New step definition for appending to a file (Aslak Hellesøy) ## [v0.1.3](https://github.com/cucumber/aruba/compare/v0.1.2...v0.1.3) * New step definition for cd (change directory) (Aslak Hellesøy) ## [v0.1.2](https://github.com/cucumber/aruba/compare/v0.1.1...v0.1.2) * Separated API from Cucumber step definitions, makes this usable without Cucumber. (Aslak Hellesøy) ## [v0.1.1](https://github.com/cucumber/aruba/compare/v0.1.0...v0.1.1) * Better Regexp escaping (David Chelimsky) ## [v0.1.0](https://github.com/cucumber/aruba/compare/ed6a175d23aaff62dbf355706996f276f304ae8b...v0.1.1) * First release (David Chelimsky and Aslak Hellesøy) ruby-aruba-0.14.1/LICENSE000066400000000000000000000021601267252361200146600ustar00rootroot00000000000000Copyright (c) 2010-2016 Aslak Hellesøy, David Chelimsky, Mike Sassak, Jarl Friis, Matt Wynne, Dennis Günnewig Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ruby-aruba-0.14.1/README.md000066400000000000000000000153721267252361200151430ustar00rootroot00000000000000[![Gem Version](https://badge.fury.io/rb/aruba.svg)](http://badge.fury.io/rb/aruba) [![Dependency Status](https://gemnasium.com/cucumber/aruba.svg)](https://gemnasium.com/cucumber/aruba) [![Code Climate](https://codeclimate.com/github/cucumber/aruba.svg)](https://codeclimate.com/github/cucumber/aruba) [![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) Build status: Linux / OS X | Windows ------------- | ------------- [![Build Status](https://travis-ci.org/cucumber/aruba.svg?branch=master)](https://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) `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. Features at a glance: * Test any command line application, implemented in any [programming language](features/getting_started/supported_programming_languages.feature) - e.g. Bash, Python, Ruby, Java, ... * Manipulate the file system and the process environment * Automatically reset state of file system and process environment between tests ## Install Add this line to your application's `Gemfile`: gem 'aruba' And then execute: $ bundle Or install it yourself as: $ gem install aruba ### Release Policy We try to be compliant to [Semantic Versioning 2.0.0](http://semver.org/spec/v2.0.0.html). ### Supported ruby versions For an up to date list of all supported ruby versions, please see our [`.travis.yml`](https://github.com/cucumber/aruba/blob/master/.travis.yml). We only test against the latest version of a version branch - most times. ## Usage Please also see this [feature test](https://github.com/cucumber/aruba/blob/master/features/getting_started/supported_testing_frameworks.feature) for the most up to date documentation. ### Initialize your project with "aruba" There's an initializer to make it easier for you to getting started. If you prefer to setup `aruba` yourself, please move on to the next section. 1. Go to your project's directory 2. Make sure, it's under version control and all changes are committed to your version control repository 3. Run one of the following commands depending on the tools you use to test your project. This assumes, that you use either `rspec`, `cucumber-ruby` or `minitest` to write the tests for your project. Besides that, your tool can be implemented in any programming language you like. ~~~bash aruba init --test-framework rspec aruba init --test-framework cucumber aruba init --test-framework minitest ~~~ ### Cucumber 1. Create a file named "features/support/env.rb" with: ~~~ruby require 'aruba/cucumber' ~~~ 2. Create a file named "features/use_aruba_with_cucumber.feature" with: ~~~ruby Feature: Cucumber Scenario: First Run Given a file named "file.txt" with: """ Hello World """ Then the file "file.txt" should contain: """ Hello World """ ~~~ 3. Run `cucumber` ### RSpec 1. Create a file named "spec/support/aruba.rb" with: ~~~ruby require 'aruba/rspec' ~~~ 2. Create a file named "spec/spec_helper.rb" with: ~~~ruby $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) if RUBY_VERSION < '1.9.3' ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) } else ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f } end ~~~ 3. Create a file named named "spec/use_aruba_with_rspec_spec.rb" with: ~~~ruby require 'spec_helper' RSpec.describe 'First Run', :type => :aruba do let(:file) { 'file.txt' } let(:content) { 'Hello World' } before(:each) { write_file file, content } it { expect(read(file)).to eq [content] } end ~~~ 4. Run `rspec` ### Minitest 1. Add a file named "test/support/aruba.rb" with: ~~~ ruby require 'aruba/api' ~~~ 2. Add a file named "test/test_helper.rb" with: ~~~ruby $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) if RUBY_VERSION < '1.9.3' ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require File.join(File.dirname(f), File.basename(f, '.rb')) } else ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each { |f| require_relative f } end ~~~ 3. Add a file named "test/use_aruba_with_minitest.rb" with: ~~~ruby $LOAD_PATH.unshift File.expand_path('../test', __FILE__) require 'test_helper' require 'minitest/autorun' class FirstRun < Minitest::Test include Aruba::Api def setup aruba_setup end def getting_started_with_aruba file = 'file.txt' content = 'Hello World' write_file file, content read(file).must_equal [content] end end ~~~ 4. Run your tests `ruby -Ilib:test test/use_aruba_with_minitest.rb` ## Documentation ### User Documentation If you're interested in our steps and API, please browse our [feature files](https://github.com/cucumber/aruba/tree/master/features). You can find a lot of examples there. A good starting point are [Getting Started](https://github.com/cucumber/aruba/tree/master/features/getting_started) and [Step Overview](https://github.com/cucumber/aruba/blob/master/features/steps/overview.feature). A more or less full list of our steps can be found [here](https://github.com/cucumber/aruba/tree/master/features/steps). Our API is documentated [here](https://github.com/cucumber/aruba/tree/master/features/api) and some more information about how to configure `aruba`, can be found [here](https://github.com/cucumber/aruba/tree/master/features/configuration). The "RSpec" matchers provided by `aruba`, are documented [here](https://github.com/cucumber/aruba/tree/master/features/matchers). You can find our documentation on [Relish](http://www.relishapp.com/cucumber/aruba/docs) as well. Unfortunately "Relish" does not like the way we structered our feature tests. So this documentation found there may be not complete. ### Developer Documentation `aruba` provides a wonderful API to be used in your tests: * Creating files/directories * Deleting files/directories * Checking file size * Checking file existence/absence * ... A full documentation of the API can be found [here](http://www.rubydoc.info/github/cucumber/aruba/master/frames). ## Contributing Please see the [CONTRIBUTING](CONTRIBUTING.md) file. ## Copyright Copyright (c) 2010-2016 Aslak Hellesøy et al. See [MIT License](LICENSE) for details. ruby-aruba-0.14.1/Rakefile000066400000000000000000000021311267252361200153160ustar00rootroot00000000000000# encoding: utf-8 require 'rubygems' require 'bundler' Bundler.setup Bundler::GemHelper.install_tasks require 'cucumber/rake/task' Cucumber::Rake::Task.new do |t| t.cucumber_opts = "" # t.cucumber_opts = "--format Cucumber::Pro --out cucumber-pro.log" if ENV['CUCUMBER_PRO_TOKEN'] t.cucumber_opts << "--format pretty" end Cucumber::Rake::Task.new(:cucumber_wip) do |t| t.cucumber_opts = "-p wip" end require 'rspec/core/rake_task' desc "Run RSpec" RSpec::Core::RakeTask.new do |spec| spec.rspec_opts = ['--color', '--format documentation', '--warnings'] end namespace :travis do desc 'Lint travis.yml' task :lint do begin require 'travis/yaml' puts 'Linting .travis.yml ... No output is good!' Travis::Yaml.parse! File.read('.travis.yml') rescue LoadError $stderr.puts 'You ruby is not supported for linting the .travis.yml' end end end task :rubocop do begin sh 'rubocop --fail-level E' rescue end end desc "Run tests, both RSpec and Cucumber" task :test => [ 'travis:lint', :rubocop, :spec, :cucumber, :cucumber_wip] task :default => :test ruby-aruba-0.14.1/TODO.md000066400000000000000000000013501267252361200147420ustar00rootroot00000000000000* Replace check filesystem permissons through a better rspec matcher * Improve documentation for matchers in file * Cleanup stdout/stderr in spawn process: It should be enough to use 'open(@process.io.stdout).read' and 'open(@process.io.stderr).read'. There's no need to rewind them. * Ensure that all processes are kill after cucumber is finished * Add variation of check and stop of command if output contains Add something like `(?: of last command)?`. If this is true, just check the last command. * Use aruba.config.exit_timeout everywhere * Fix problem with long running commands in background: Since we need to stop all commands to access the status of the last command stopped, we have problems with long running commands ruby-aruba-0.14.1/appveyor.yml000066400000000000000000000012711267252361200162450ustar00rootroot00000000000000version: "{build}" # This will build all PRs targetting matching branches. # Without this, each PR builds twice -- once for the PR branch HEAD, # and once for the merge commit that github creates for each mergable PR. branches: only: - master # Disable normal Windows builds in favor of our test script. build: off install: - SET PATH=C:\Ruby%ruby_version%\bin;%PATH% - ruby --version - gem --version - gem install bundler - bundler --version - bundle install - cinst ansicon test_script: - bundle exec rake test --trace environment: matrix: - ruby_version: '18' - ruby_version: '19' - ruby_version: '20' - ruby_version: '21' - ruby_version: '22' ruby-aruba-0.14.1/aruba.gemspec000066400000000000000000000034711267252361200163200ustar00rootroot00000000000000# -*- encoding: utf-8 -*- lib = ::File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'aruba/version' Gem::Specification.new do |s| s.name = 'aruba' s.version = Aruba::VERSION s.authors = ["Aslak Hellesøy", "David Chelimsky", "Mike Sassak", "Matt Wynne", "Jarl Friis", "Dennis Günnewig"] s.description = 'Extension for popular TDD and BDD frameworks like "Cucumber", "RSpec" and "Minitest" to make testing commandline applications meaningful, easy and fun.' s.summary = "aruba-#{s.version}" s.license = 'MIT' s.email = 'cukes@googlegroups.com' s.homepage = 'http://github.com/cucumber/aruba' s.add_runtime_dependency 'cucumber', '>= 1.3.19' s.add_runtime_dependency 'childprocess', '~> 0.5.6' s.add_runtime_dependency 'ffi', '~> 1.9.10' s.add_runtime_dependency 'rspec-expectations', '>= 2.99' s.add_runtime_dependency 'contracts', '~> 0.9' s.add_runtime_dependency 'thor', '~> 0.19' s.add_development_dependency 'bundler', '~> 1.11' s.rubygems_version = ">= 1.6.1" if Aruba::VERSION >= '1' s.required_ruby_version = '>= 1.9.3' else s.required_ruby_version = '>= 1.8.7' s.post_install_message = <<-EOS Use on ruby 1.8.7 * Make sure you add something like that to your `Gemfile`. Otherwise you will get cucumber > 2 and this will fail on ruby 1.8.7 gem 'cucumber', '~> 1.3.20' 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 EOS end s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.rdoc_options = ["--charset=UTF-8"] s.require_path = "lib" end ruby-aruba-0.14.1/bin/000077500000000000000000000000001267252361200144245ustar00rootroot00000000000000ruby-aruba-0.14.1/bin/aruba000077500000000000000000000001621267252361200154430ustar00rootroot00000000000000#!/usr/bin/env ruby $LOAD_PATH << File.expand_path('../../lib', __FILE__) require 'aruba/cli' Aruba::Cli.start ruby-aruba-0.14.1/config/000077500000000000000000000000001267252361200151215ustar00rootroot00000000000000ruby-aruba-0.14.1/config/.gitignore000066400000000000000000000000151267252361200171050ustar00rootroot00000000000000aruba-rvm.ymlruby-aruba-0.14.1/cucumber.yml000066400000000000000000000027641267252361200162150ustar00rootroot00000000000000<% $LOAD_PATH << ::File.expand_path('../lib', __FILE__) require 'aruba/version' require 'ffi' java_version = (RUBY_DESCRIPTION.match(/.*?on.*?(1\.[\d]\..*? )/))[1] if defined?(JRUBY_VERSION) std_opts = "--color --exclude features/fixtures --require features --tags ~@unsupported-on" java_default_opts = "--tags ~@wip-jruby-java-1.6" if defined?(JRUBY_VERSION) && (java_version < '1.7.0') java_wip_opts = "--tags @wip-jruby-java-1.6:3" if defined?(JRUBY_VERSION) && (java_version < '1.7.0') ignore_opts = [] ignore_opts << '--tags ~@ignore' ignore_opts << '--tags ~@unsupported-on-platform-java' if RUBY_PLATFORM.include? 'java' ignore_opts << '--tags ~@unsupported-on-platform-mri' if !RUBY_PLATFORM.include? 'java' ignore_opts << '--tags ~@unsupported-on-platform-windows' if FFI::Platform.windows? ignore_opts << '--tags ~@unsupported-on-platform-unix' if FFI::Platform.unix? ignore_opts << '--tags ~@unsupported-on-platform-mac' if FFI::Platform.mac? ignore_opts << '--tags ~@unsupported-on-ruby-older-2' if RUBY_VERSION < '2' ignore_opts << '--tags ~@unsupported-on-ruby-older-193' if RUBY_VERSION < '1.9.3' ignore_opts << '--tags ~@unsupported-on-ruby-older-19' if RUBY_VERSION < '1.9' ignore_opts << '--tags ~@requires-aruba-version-1' if Aruba::VERSION < '1' ignore_opts = ignore_opts.join(' ') %> default: <%= std_opts %> --tags ~@wip <%= java_default_opts %> <%= ignore_opts %> wip: <%= std_opts %> --wip --tags @wip:3 <%= java_wip_opts %> <%= ignore_opts %> ruby-aruba-0.14.1/doc/000077500000000000000000000000001267252361200144215ustar00rootroot00000000000000ruby-aruba-0.14.1/doc/dependency_decisions.yml000066400000000000000000000004271267252361200213250ustar00rootroot00000000000000--- - - :whitelist - MIT - :who: :why: :when: 2015-04-28 13:38:19.583103100 Z - - :ignore_group - development - :who: :why: :when: 2015-04-28 13:39:28.340867782 Z - - :whitelist - BSD - :who: :why: :when: 2015-04-28 13:39:40.984464786 Z ruby-aruba-0.14.1/features/000077500000000000000000000000001267252361200154725ustar00rootroot00000000000000ruby-aruba-0.14.1/features/.nav000066400000000000000000000062031267252361200162600ustar00rootroot00000000000000- README.md - getting_started (Getting Started): - install.feature (Install Aruba) - supported_programming_languages.feature (Supportet Programming Languages) - ruby_api (Ruby API): - expand_path.feature (#expand_path) - cleanup_aruba_directory.feature (#setup_aruba) - run.feature (#run) - which.feature (#which) - append_environment_variable.feature (#append_environment_variable) - prepend_environment_variable.feature (#prepend_environment_variable) - set_environment_variable.feature (#set_environment_variable) - cd.feature (#cd) - create_directory.feature (#create_directory) - disk_usage.feature (#disk_usage) - does_exist.feature (#exist?) - is_absolute.feature (#absolute?) - filesystem/is_directory.feature (#directory?) - is_file.feature (#file?) - is_relative.feature(#relative?) - move.feature (#move) - file_system_commands.feature - command.feature (Before Hook) - command.feature (After Hook) - cucumber (Cucumber): - debug_command.feature (Debug Commmands) - environment_variables.feature (Environment Variables) - flushing.feature (Flush Output) - interactive.feature (Interactive Commands) - all_output.feature (Command Output) - stdout.feature (STDOUT) - configuration (Configuration): - exit_timeout.feature (Exit Timeout) - fixtures_directories.feature (Fixtures Directories) - fixtures_path_prefix.feature (Fixture Path Prefix) - home_directory.feature (Home Directory) - io_timeout.feature (IO Wait Timeout) - keep_ansi.feature (Keep ANSI output) - log_level.feature (Log Level) - physical_block_size.feature (Physical Block Size) - root_directory.feature (Root Directory) - working_directory.feature (Working Directory) - rspec (RSpec): - getting_started.feature (Integration) - include_an_object.feature (Matcher: Include an Object) - have_sub_directory.feature (Matcher: Have Sub Directory) - be_existing_file.feature (Matcher: Be Existing File) - have_file_content.feature (Matcher: Have File Content) - have_file_size.feature (Matcher: Have File Size) - be_an_absolute_path.feature (Matcher: Be Absolute Path) - be_an_existing_path.feature (Matcher: Be Existing Path) - have_permissions.feature (Matcher: Have Permissions) - timeouts.feature (Matcher: Timeouts) - cucumber (Cucumber): - announce.feature (Announce Information to User) - exit_statuses.feature (Exit Status of Commands) - in_process.feature (Start Commands in Process) - run.feature (Run Commands) - home_variable.feature (Modify HOME-Variable) - set_environment_variable.feature (Set Environment variables) - copy.feature (Copy files/directories) - create_directory.feature (Create Directories) - create_file.feature (Create Files) - file_content.feature (Use File Content) - move.feature (Move files/directories) - overwrite_file.feature (Overwrite Files) - use_fixture.feature (Use Fixtures) - output.feature (Output) - utf-8.feature (Support for UTF-8-strings) - development (Development): - build.feature (Build Aruba) - test.feature (Test Aruba) ruby-aruba-0.14.1/features/api/000077500000000000000000000000001267252361200162435ustar00rootroot00000000000000ruby-aruba-0.14.1/features/api/command/000077500000000000000000000000001267252361200176615ustar00rootroot00000000000000ruby-aruba-0.14.1/features/api/command/find_command.feature000066400000000000000000000046641267252361200236660ustar00rootroot00000000000000Feature: Find a started command This feature is experimental and may change without further notice. Background: Given I use a fixture named "cli-app" Scenario: Existing command Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('echo hello') } let(:command) { find_command('echo hello') } before(:each) { stop_all_commands } it { expect(command).to be_successfully_executed } it { expect(command.commandline).to eq 'echo hello' } end """ When I run `rspec` Then the specs should all pass Scenario: Non-Existing command Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do let(:command) { find_command('echo hello') } it { expect{ command }.to raise_error Aruba::CommandNotFoundError } it { expect{ command.commandline }.to raise_error Aruba::CommandNotFoundError } end """ When I run `rspec` Then the specs should all pass Scenario: Multiple commands Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('echo hello1') } before(:each) { run('echo hello2') } let(:command) { find_command('echo hello1') } before(:each) { stop_all_commands } it { expect(command).to be_successfully_executed } it { expect(command.commandline).to eq 'echo hello1' } end """ When I run `rspec` Then the specs should all pass Scenario: Multiple commands with same commandline If searches in reverse. So it finds the last command started with the given commandline. Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { set_environment_variable 'ENV_VAR', '1' } before(:each) { run('bash -c "echo -n $ENV_VAR"') } before(:each) { set_environment_variable 'ENV_VAR', '2' } before(:each) { run('bash -c "echo -n $ENV_VAR"') } let(:command) { find_command('bash -c "echo -n $ENV_VAR"') } before(:each) { stop_all_commands } it { expect(command).to be_successfully_executed } it { expect(command.stdout).to eq '2' } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/last_command_started.feature000066400000000000000000000027001267252361200254240ustar00rootroot00000000000000Feature: Return last command started Background: Given I use a fixture named "cli-app" Scenario: A command has been started Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('echo hello') } before(:each) { stop_all_commands } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started.commandline).to eq 'echo hello' } end """ When I run `rspec` Then the specs should all pass Scenario: Multiple commands have been started Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('echo hello') } before(:each) { run('echo world') } before(:each) { stop_all_commands } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started.commandline).to eq 'echo world' } end """ When I run `rspec` Then the specs should all pass Scenario: No command has been started Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do it { expect{ last_command_started.commandline }.to raise_error Aruba::NoCommandHasBeenStartedError } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/last_command_stopped.feature000066400000000000000000000051171267252361200254410ustar00rootroot00000000000000Feature: Return last command stopped Background: Given I use a fixture named "cli-app" Scenario: A command has been started Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('echo hello') } before(:each) { stop_all_commands } it { expect(last_command_stopped).to be_successfully_executed } it { expect(last_command_stopped.commandline).to eq 'echo hello' } end """ When I run `rspec` Then the specs should all pass Scenario: Multiple commands have been started and all are stopped Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('echo hello') } before(:each) { run('echo world') } before(:each) { stop_all_commands } it { expect(last_command_stopped).to be_successfully_executed } it { expect(last_command_stopped.commandline).to eq 'echo world' } end """ When I run `rspec` Then the specs should all pass Scenario: Multiple commands have been started and a single one is stopped Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('echo hello') } before(:each) { find_command('echo hello').stop } before(:each) { run('echo world') } it { expect(last_command_stopped).to be_successfully_executed } it { expect(last_command_stopped.commandline).to eq 'echo hello' } end """ When I run `rspec` Then the specs should all pass @requires-aruba-version-1 Scenario: No command has been started Given a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do it { expect{ last_command_stopped.commandline }.to raise_error Aruba::NoCommandHasBeenStoppedError } end """ When I run `rspec` Then the specs should all pass @requires-aruba-version-1 Scenario: No command has been stopped Given an executable named "bin/cli" with: """bash #!/bin/bash while [ true ]; do sleep 1; done """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } it { expect{ last_command_stopped.commandline }.to raise_error Aruba::NoCommandHasBeenStoppedError } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/run.feature000066400000000000000000000240551267252361200220500ustar00rootroot00000000000000Feature: Run command To run a command use the `#run`-method. There are some configuration options which are relevant here: - `startup_wait_time`: Given this option `aruba` waits n seconds after it started the command. This is most useful when using `#run()` and not really makes sense for `#run_simple()`. You can use `#run()` + `startup_wait_time` to start background jobs. - `exit_timeout`: The exit timeout is used, when `aruba` waits for a command to finished. - `io_wait_timeout`: The io wait timeout is used, when you access `stdout` or `stderr` of a command. Background: Given I use a fixture named "cli-app" Scenario: Existing executable Given an executable named "bin/cli" with: """bash #!/bin/bash exit 0 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } it { expect(last_command_started).to be_successfully_executed } end """ When I run `rspec` Then the specs should all pass Scenario: Relative path to executable Given an executable named "bin/cli" with: """bash #!/bin/bash exit 0 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('bin/cli') } it { expect(last_command_started).to be_successfully_executed } end """ When I run `rspec` Then the specs should all pass Scenario: Non-existing executable Given a file named "bin/cli" does not exist And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Find path for command', :type => :aruba do it { expect { run('cli') }.to raise_error Aruba::LaunchError, /Command "cli" not found in PATH-variable/ } end """ When I run `rspec` Then the specs should all pass Scenario: Command with long startup phase If you have got a command with a long startup phase or use `ruby` together with `bundler`, you should consider using the `startup_wait_time`-option. Otherwise methods like `#send_signal` don't work since they require the command to be running and have setup it's signal handler. Given an executable named "bin/cli" with: """bash #!/usr/bin/env bash function initialize_script { sleep 2 } function do_some_work { echo "Hello, Aruba is working" } function recurring_work { echo "Hello, Aruba here" } function stop_script { exit 0 } trap recurring_work HUP trap stop_script TERM initialize_script do_some_work while [ true ]; do sleep 1; done """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 2 do before(:each) { run('cli') } before(:each) { last_command_started.send_signal 'HUP' } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started).to have_output /Hello, Aruba is working/ } it { expect(last_command_started).to have_output /Hello, Aruba here/ } end """ When I run `rspec` Then the specs should all pass Scenario: Long running command If you have got a "long running" command, you should consider using the `exit_timeout`-option. Given an executable named "bin/cli" with: """bash #!/usr/bin/env bash function do_some_work { sleep 2 echo "Hello, Aruba here" } do_some_work """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 3 do before(:each) { run('cli') } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started).to have_output /Hello, Aruba here/ } end """ When I run `rspec` Then the specs should all pass Scenario: Mixing commands with long and short startup phase (deprecated) If you commands with a long and short startup phases, you should consider using the `startup_wait_time`-option local to the `#run`-call. Given an executable named "bin/cli1" with: """bash #!/usr/bin/env bash function initialize_script { sleep 2 } function do_some_work { echo "Hello, Aruba is working" } function recurring_work { echo "Hello, Aruba here" } function stop_script { exit 0 } trap recurring_work HUP trap stop_script TERM initialize_script do_some_work while [ true ]; do sleep 0.2; done """ And an executable named "bin/cli2" with: """bash #!/usr/bin/env bash function initialize_script { sleep 0 } function do_some_work { echo "Hello, Aruba is working" } function recurring_work { echo "Hello, Aruba here" } function stop_script { exit 0 } trap recurring_work HUP trap stop_script TERM initialize_script do_some_work while [ true ]; do sleep 0.2; done """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1 do before(:each) { run('cli1', 3, 0.1, 'TERM', 2) } before(:each) { run('cli2', 3, 0.1, 'TERM', 1) } before(:each) { last_command_started.send_signal 'HUP' } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started).to have_output /Hello, Aruba is working/ } it { expect(last_command_started).to have_output /Hello, Aruba here/ } end """ When I run `rspec` Then the specs should all pass Scenario: Mixing commands with long and short startup phase If you commands with a long and short startup phases, you should consider using the `startup_wait_time`-option local to the `#run`-call. Given an executable named "bin/cli1" with: """bash #!/usr/bin/env bash function initialize_script { sleep 2 } function do_some_work { echo "Hello, Aruba is working" } function recurring_work { echo "Hello, Aruba here" } function stop_script { exit 0 } trap recurring_work HUP trap stop_script TERM initialize_script do_some_work while [ true ]; do sleep 0.2; done """ And an executable named "bin/cli2" with: """bash #!/usr/bin/env bash function initialize_script { sleep 0 } function do_some_work { echo "Hello, Aruba is working" } function recurring_work { echo "Hello, Aruba here" } function stop_script { exit 0 } trap recurring_work HUP trap stop_script TERM initialize_script do_some_work while [ true ]; do sleep 0.2; done """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1 do before(:each) { run('cli1', :startup_wait_time => 2) } before(:each) { run('cli2', :startup_wait_time => 1) } before(:each) { last_command_started.send_signal 'HUP' } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started).to have_output /Hello, Aruba is working/ } it { expect(last_command_started).to have_output /Hello, Aruba here/ } end """ When I run `rspec` Then the specs should all pass Scenario: Mixing long and short running commands (deprecated) If need to mix "long running" and "short running" commands, you should consider using the `exit_timeout`-option local to the `#run`-method. Given an executable named "bin/cli1" with: """bash #!/usr/bin/env bash function do_some_work { sleep 2 echo "Hello, Aruba here" } do_some_work """ And an executable named "bin/cli2" with: """bash #!/usr/bin/env bash function do_some_work { echo "Hello, Aruba here" } do_some_work """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli1', 3) } before(:each) { run('cli2', 1) } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started).to have_output /Hello, Aruba here/ } end """ When I run `rspec` Then the specs should all pass Scenario: Mixing long and short running commands If need to mix "long running" and "short running" commands, you should consider using the `exit_timeout`-option local to the `#run`-method. Given an executable named "bin/cli1" with: """bash #!/usr/bin/env bash function do_some_work { sleep 2 echo "Hello, Aruba here" } do_some_work """ And an executable named "bin/cli2" with: """bash #!/usr/bin/env bash function do_some_work { echo "Hello, Aruba here" } do_some_work """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli1', :exit_timeout => 3) } before(:each) { run('cli2', :exit_timeout => 1) } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started).to have_output /Hello, Aruba here/ } end """ When I run `rspec` Then the specs should all pass Scenario: Starting command twice fails Given an executable named "bin/cli" with: """bash #!/bin/bash exit 0 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } let!(:found_command) { find_command('cli') } it { expect { found_command.start }.to raise_error Aruba::CommandAlreadyStartedError } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/run_simple.feature000066400000000000000000000140641267252361200234200ustar00rootroot00000000000000Feature: Run command To run a command use the `#run`-method. There are some configuration options which are relevant here: - `fail_on_error`: Given this option is `true`, `aruba` fails if the `command` fails to run - exit code <> 0. For all other options see [run.feature](run.feature). Background: Given I use a fixture named "cli-app" Scenario: Require executable to succeed (by default value) Given an executable named "bin/cli" with: """bash #!/bin/bash exit 1 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do it { expect { run_simple('cli') }.to raise_error RSpec::Expectations::ExpectationNotMetError } end """ When I run `rspec` Then the specs should all pass Scenario: Require executable to succeed (set by option) Given an executable named "bin/cli" with: """bash #!/bin/bash exit 1 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do it { expect { run_simple('cli', :fail_on_error => true) }.to raise_error } end """ When I run `rspec` Then the specs should all pass Scenario: Require executable to succeed (set by option, deprecated) Given an executable named "bin/cli" with: """bash #!/bin/bash exit 1 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do it { expect { run_simple('cli', true) }.to raise_error } end """ When I run `rspec` Then the specs should all pass Scenario: Ignore failure of executable (set by option) Given an executable named "bin/cli" with: """bash #!/bin/bash exit 1 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do it { expect { run_simple('cli', :fail_on_error => false) }.not_to raise_error } end """ When I run `rspec` Then the specs should all pass Scenario: Ignore failure of executable (set by option, deprecated) Given an executable named "bin/cli" with: """bash #!/bin/bash exit 1 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do it { expect { run_simple('cli', false) }.not_to raise_error } end """ When I run `rspec` Then the specs should all pass Scenario: Command with long startup phase If you have got a command with a long startup phase or use `ruby` together with `bundler`, you should consider using the `startup_wait_time`-option. Otherwise methods like `#send_signal` don't work since they require the command to be running and have setup it's signal handler. Given an executable named "bin/cli" with: """bash #!/usr/bin/env bash function initialize_script { sleep 2 } function do_some_work { echo "Hello, Aruba is working" } initialize_script do_some_work exit 0 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 2 do before(:each) { run_simple('cli') } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started).to have_output /Hello, Aruba is working/ } end """ When I run `rspec` Then the specs should all pass Scenario: Long running command If you have got a "long running" command, you should consider using the `exit_timeout`-option. Given an executable named "bin/cli" with: """bash #!/usr/bin/env bash function do_some_work { sleep 2 echo "Hello, Aruba here" } do_some_work """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 3 do before(:each) { run_simple('cli') } it { expect(last_command_started).to be_successfully_executed } it { expect(last_command_started).to have_output /Hello, Aruba here/ } end """ When I run `rspec` Then the specs should all pass Scenario: Sending signals to commands started with `#run_simple()` Sending signals to a command which is started by `#run_simple()` does not make sense. The command is stopped internally when its exit status is checked. Given an executable named "bin/cli" with: """bash #!/usr/bin/env bash function initialize_script { sleep 1 } function cleanup_script { sleep 1 } function do_some_work { echo "Hello, Aruba is working" } trap stop_script TERM initialize_script do_some_work cleanup_script exit 0 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 2, :startup_wait_time => 1 do before(:each) { run_simple('cli') } it { expect { last_command_started.send_signal 'HUP' }.to raise_error Aruba::CommandAlreadyStoppedError } end """ When I run `rspec` Then the specs should all pass Scenario: Activate announcer channels on failure Given an executable named "bin/cli" with: """bash #!/bin/bash echo "Hello, I'm STDOUT" echo "Hello, I'm STDERR" 1>&2 exit 1 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' Aruba.configure do |config| config.activate_announcer_on_command_failure = [:stdout, :stderr] end RSpec.describe 'Run command', :type => :aruba do it { expect { run_simple('cli', :fail_on_error => true) }.to_not raise_error } end """ When I run `rspec` Then the specs should not pass And the output should contain: """ <<-STDOUT Hello, I'm STDOUT STDOUT <<-STDERR Hello, I'm STDERR STDERR """ ruby-aruba-0.14.1/features/api/command/send_signal.feature000066400000000000000000000027151267252361200235310ustar00rootroot00000000000000Feature: Send running command a signal You can send a running command a signal using `last_command_started#send_signal`. This is only supported with `aruba.config.command_launcher = :spawn` (default). Background: Given I use a fixture named "cli-app" Scenario: Existing executable Given an executable named "bin/cli" with: """ruby #!/usr/bin/env bash function hup { echo 'Exit...' >&2 exit 0 } trap hup HUP while [ true ]; do sleep 1; done """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 5 do before(:each) { run('cli') } before(:each) { last_command_started.send_signal 'HUP' } it { expect(last_command_started).to have_output /Exit/ } end """ When I run `rspec` Then the specs should all pass Scenario: Dying command Given an executable named "bin/cli" with: """ruby #!/usr/bin/env bash exit 1 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 1, :startup_wait_time => 5 do before(:each) { run('cli') } it { expect { last_command_started.send_signal 'HUP' }.to raise_error Aruba::CommandAlreadyStoppedError, /Command "cli" with PID/ } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/stderr.feature000066400000000000000000000024171267252361200225450ustar00rootroot00000000000000Feature: Access STDERR of command You may need to `#stop_all_commands` before accessing `#stderr` of a single command - e.g. `#last_command_started`. Background: Given I use a fixture named "cli-app" And the default aruba io wait timeout is 1 seconds Scenario: Existing executable Given an executable named "bin/cli" with: """bash #!/bin/bash echo 'Hello, Aruba!' >&2 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(last_command_started.stderr).to start_with 'Hello' } end """ When I run `rspec` Then the specs should all pass Scenario: Waiting for output to "appear" after 2 seconds Given an executable named "bin/cli" with: """bash #!/bin/bash sleep 1 echo 'Hello, Aruba' >&2 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :io_wait_timeout => 2 do before(:each) { run('cli') } it { expect(last_command_started.stderr).to start_with 'Hello' } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/stdout.feature000066400000000000000000000024071267252361200225630ustar00rootroot00000000000000Feature: Access STDOUT of command You may need to `#stop_all_commands` before accessing `#stdout` of a single command - e.g. `#last_command_started`. Background: Given I use a fixture named "cli-app" And the default aruba io wait timeout is 1 seconds Scenario: Existing executable Given an executable named "bin/cli" with: """bash #!/bin/bash echo 'Hello, Aruba!' """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(last_command_started.stdout).to start_with 'Hello' } end """ When I run `rspec` Then the specs should all pass Scenario: Waiting for output to "appear" after 2 seconds Given an executable named "bin/cli" with: """bash #!/bin/bash sleep 1 echo 'Hello, Aruba' """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :io_wait_timeout => 2 do before(:each) { run('cli') } it { expect(last_command_started.stdout).to start_with 'Hello' } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/stop.feature000066400000000000000000000061151267252361200222260ustar00rootroot00000000000000Feature: Stop command To stop commands via API you can do the following: - `last_command_started.stop` - `find_command('command').stop` But normally there's no need to stop a command manually. All matchers handling commands make sure, that they stop ALL command before check actual against expected. Background: Given I use a fixture named "cli-app" Scenario: Stop command started last Given an executable named "bin/cli" with: """bash #!/bin/bash function term { exit 0 } trap term TERM while [ true ]; do sleep 1; done """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { last_command_started.stop } it { expect(last_command_started).to be_successfully_executed } end """ When I run `rspec` Then the specs should all pass Scenario: Find and stop command Given an executable named "bin/cli" with: """bash #!/bin/bash function term { exit 0 } trap term TERM while [ true ]; do sleep 1; done """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { find_command('cli').stop } it { expect(last_command_started).to be_successfully_executed } end """ When I run `rspec` Then the specs should all pass Scenario: Stop successful command with configured signal Given an executable named "bin/cli" with: """bash #!/bin/bash function hup { echo "Exit..." exit 0 } function term { echo "No! No exit here. Try HUP. I stop the command with exit 1." exit 1 } trap hup HUP trap term TERM while [ true ]; do sleep 1; done """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' Aruba.configure do |config| config.stop_signal = 'HUP' config.exit_timeout = 1 end RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } it { expect(last_command_started).to be_successfully_executed } end """ When I run `rspec` Then the specs should all pass Scenario: Stop unsuccessful command with configured signal Given an executable named "bin/cli" with: """bash #!/bin/bash function hup { echo "Exit..." exit 2 } function term { echo "No! No exit here. Try HUP. I stop the command with exit 1." exit 1 } trap hup HUP trap term TERM while [ true ]; do sleep 1; done """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' Aruba.configure do |config| config.stop_signal = 'HUP' config.exit_timeout = 1 end RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } it { expect(last_command_started).to have_exit_status 2 } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/stop_all_commands.feature000066400000000000000000000026051267252361200247370ustar00rootroot00000000000000Feature: Stop all commands To stop all running commands use the `#stop_all_commands`-method. Background: Given I use a fixture named "cli-app" Scenario: Multiple commands are running Given an executable named "bin/cli" with: """bash #!/bin/bash sleep 3 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 5 do before(:each) { run('cli') } before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(all_commands).to all be_stopped } end """ When I run `rspec` Then the specs should all pass Scenario: Stop all commands for which the block returns true Given an executable named "bin/cli" with: """bash #!/bin/bash sleep 1 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 2 do before(:each) { @cmd1 = run('cli') } before(:each) { @cmd2 = run('cli') } before(:each) { @cmd3 = run('sleep 1') } before(:each) { stop_all_commands { |c| c.commandline == 'cli' } } it { expect(@cmd1).to be_stopped } it { expect(@cmd2).to be_stopped } it { expect(@cmd3).not_to be_stopped } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/terminate_all_commands.feature000066400000000000000000000026431267252361200257440ustar00rootroot00000000000000Feature: Terminate all commands To terminate all running commands use the `#terminate_all_commands`-method. Background: Given I use a fixture named "cli-app" Scenario: Multiple commands are running Given an executable named "bin/cli" with: """bash #!/bin/bash sleep 3 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 5 do before(:each) { run('cli') } before(:each) { run('cli') } before(:each) { terminate_all_commands } it { expect(all_commands).to all be_stopped } end """ When I run `rspec` Then the specs should all pass Scenario: Terminate all commands for which the block returns true Given an executable named "bin/cli" with: """bash #!/bin/bash sleep 1 """ And a file named "spec/run_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :exit_timeout => 2 do before(:each) { @cmd1 = run('cli') } before(:each) { @cmd2 = run('cli') } before(:each) { @cmd3 = run('sleep 1') } before(:each) { terminate_all_commands { |c| c.commandline == 'cli' } } it { expect(@cmd1).to be_stopped } it { expect(@cmd2).to be_stopped } it { expect(@cmd3).not_to be_stopped } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/command/which.feature000066400000000000000000000017101267252361200223370ustar00rootroot00000000000000Feature: Get path to command Sometimes you only know a commands name, but not where to find it. Here comes `which` to the rescue. Background: Given I use a fixture named "cli-app" Scenario: Existing executable Given an executable named "bin/cli" with: """bash #!/bin/bash exit 0 """ And a file named "spec/which_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Find path for command', :type => :aruba do it { expect(which('cli')).to match %r{tmp/aruba/cli-app/bin/cli} } end """ When I run `rspec` Then the specs should all pass Scenario: Non-existing executable Given a file named "bin/cli" does not exist And a file named "spec/which_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Find path for command', :type => :aruba do it { expect(which('cli')).to be_nil } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/core/000077500000000000000000000000001267252361200171735ustar00rootroot00000000000000ruby-aruba-0.14.1/features/api/core/expand_path.feature000066400000000000000000000053161267252361200230500ustar00rootroot00000000000000Feature: Expand paths with aruba There are quite a few uses cases why you want to expand a path. `aruba` helps you with this by providing you the `expand_path`-method. This method expands paths relative to the `aruba.current_directory`-directory. Background: Given I use the fixture "cli-app" Scenario: Use relative path Given a file named "spec/expand_path_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Expand path', :type => :aruba do let(:path) { 'path/to/dir' } it { expect(expand_path(path)).to eq File.join(aruba.root_directory, aruba.current_directory, path) } end """ When I run `rspec` Then the specs should all pass Scenario: Change directory using cd Given a file named "spec/expand_path_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Expand path', :type => :aruba do let(:path) { 'path/to/dir' } let(:directory) { 'dir1' } before(:each) { create_directory(directory) } before(:each) { cd(directory) } it { expect(expand_path(path)).to eq File.join(aruba.root_directory, aruba.current_directory, path) } end """ When I run `rspec` Then the specs should all pass Scenario: Warn if aruba's working directory does not exist Given a file named "spec/expand_path_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Expand path', :type => :aruba do before(:each) { remove('.') } let(:path) { 'path/to/dir' } it { expect { expand_path(path) }.to output(/working directory does not exist/).to_stderr } end """ When I run `rspec` Then the specs should all pass Scenario: Use ~ in path Now this useses the HOME-variable from your normal shell HOME-variable. From 1.0.0 on HOME will be `File.join(aruba.config.root_directory, aruba.config.working_directory)`. If you want HOME have some other value, you need to configure it explicitly via `Aruba.configure {}`. Given a file named "spec/expand_path_spec.rb" with: """ruby require 'spec_helper' # Old before 1.0.0 RSpec.describe 'Expand path', :type => :aruba do let(:path) { '~/path/to/dir' } it { expect(expand_path(path)).to match %r } end # New from 1.0.0 RSpec.describe 'Expand path', :type => :aruba do let(:path) { '~/path/to/dir' } before(:each) do set_environment_variable('HOME', File.join(aruba.config.root_directory, aruba.config.working_directory)) end it { expect(expand_path(path)).to eq File.join(aruba.config.root_directory, aruba.config.working_directory, 'path/to/dir') } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/environment/000077500000000000000000000000001267252361200206075ustar00rootroot00000000000000ruby-aruba-0.14.1/features/api/environment/append_environment_variable.feature000066400000000000000000000077261267252361200277400ustar00rootroot00000000000000Feature: Append environment variable It is quite handy to modify the environment of a process. To make this possible, `aruba` provides several methods. One of these is `#append_environment_variable`. Using this variable appends a given value to an existing one. If the variable does not exist, it is created with the given value. Each variable name and each value is converted to a string. Otherwise `ruby` would complain about an invalid argument. To make use of a variable you can either use `#run` and the like or `#with_environment`. Background: Given I use the fixture "cli-app" Scenario: Non-existing variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Long running command', :type => :aruba do before(:each) { append_environment_variable 'LONG_LONG_VARIABLE', 'a' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=a' } end """ When I run `rspec` Then the specs should all pass Scenario: Existing inner variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Long running command', :type => :aruba do before(:each) { append_environment_variable 'LONG_LONG_VARIABLE', 'a' } before(:each) { append_environment_variable 'LONG_LONG_VARIABLE', 'b' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=ab' } end """ When I run `rspec` Then the specs should all pass Scenario: Existing outer variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = 'a' RSpec.describe 'Long running command', :type => :aruba do before(:each) { append_environment_variable 'REALLY_LONG_LONG_VARIABLE', 'b' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'REALLY_LONG_LONG_VARIABLE=ab' } # Has no effect here, is not in block and not a command `run` it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'a' } end """ When I run `rspec` Then the specs should all pass Scenario: Run some ruby code with previously set environment Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = 'a' RSpec.describe 'Long running command', :type => :aruba do before(:each) { append_environment_variable 'REALLY_LONG_LONG_VARIABLE', 'b' } before(:each) { run('env') } before(:each) { stop_all_commands } it do with_environment do expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'ab' end end # Has no effect here, is not in block and not a command `run` it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'a' } end """ When I run `rspec` Then the specs should all pass Scenario: Run some ruby code with local environment If you pass the same variable to the block it will not be appended, but overwrites the variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = 'a' RSpec.describe 'Long running command', :type => :aruba do before(:each) { append_environment_variable 'REALLY_LONG_LONG_VARIABLE', 'b' } before(:each) { run('env') } before(:each) { stop_all_commands } it do with_environment 'REALLY_LONG_LONG_VARIABLE' => 'a' do expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'a' end end # Has no effect here, is not in block and not a command `run` it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'a' } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/environment/delete_environment_variable.feature000066400000000000000000000037421267252361200277250ustar00rootroot00000000000000Feature: Delete existing environment variable via API-method It is quite handy to modify the environment of a process. To make this possible, `aruba` provides several methods. One of these is `#delete_environment_variable`. Using this remove an existing variable. Background: Given I use the fixture "cli-app" Scenario: Non-existing variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Long running command', :type => :aruba do before(:each) { delete_environment_variable 'LONG_LONG_VARIABLE' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).not_to include 'LONG_LONG_VARIABLE=1' } end """ When I run `rspec` Then the specs should all pass Scenario: Existing variable set from within the test Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Long running command', :type => :aruba do before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '1' } before(:each) { delete_environment_variable 'LONG_LONG_VARIABLE' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).not_to include 'LONG_LONG_VARIABLE' } end """ When I run `rspec` Then the specs should all pass Scenario: Existing variable set by some outer parent process Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = '1' RSpec.describe 'Environment command', :type => :aruba do before(:each) { delete_environment_variable 'REALLY_LONG_LONG_VARIABLE' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).not_to include 'REALLY_LONG_LONG_VARIABLE' } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/environment/prepend_environment_variable.feature000066400000000000000000000077401267252361200301220ustar00rootroot00000000000000Feature: Prepend environment variable It is quite handy to modify the environment of a process. To make this possible, `aruba` provides several methods. One of these is `#prepend_environment_variable`. Using this variable prepends a given value to an existing one. If the variable does not exist, it is created with the given value. Each variable name and each value is converted to a string. Otherwise `ruby` would complain about an invalid argument. To make use of a variable you can either use `#run` and the like or `#with_environment`. Background: Given I use the fixture "cli-app" Scenario: Non-existing variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Long running command', :type => :aruba do before(:each) { prepend_environment_variable 'LONG_LONG_VARIABLE', 'a' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=a' } end """ When I run `rspec` Then the specs should all pass Scenario: Existing inner variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Long running command', :type => :aruba do before(:each) { prepend_environment_variable 'LONG_LONG_VARIABLE', 'a' } before(:each) { prepend_environment_variable 'LONG_LONG_VARIABLE', 'b' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=ba' } end """ When I run `rspec` Then the specs should all pass Scenario: Existing outer variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = 'a' RSpec.describe 'Long running command', :type => :aruba do before(:each) { prepend_environment_variable 'REALLY_LONG_LONG_VARIABLE', 'b' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'REALLY_LONG_LONG_VARIABLE=ba' } # Has no effect here, is not in block and not a command `run` it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'a' } end """ When I run `rspec` Then the specs should all pass Scenario: Run some ruby code with previously set environment Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = 'a' RSpec.describe 'Long running command', :type => :aruba do before(:each) { prepend_environment_variable 'REALLY_LONG_LONG_VARIABLE', 'b' } before(:each) { run('env') } before(:each) { stop_all_commands } it do with_environment do expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'ba' end end # Has no effect here, is not in block and not a command `run` it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'a' } end """ When I run `rspec` Then the specs should all pass Scenario: Run some ruby code with local environment If you pass the same variable to the block it will not be prepended, but overwrites the variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = 'a' RSpec.describe 'Long running command', :type => :aruba do before(:each) { prepend_environment_variable 'REALLY_LONG_LONG_VARIABLE', 'b' } before(:each) { run('env') } before(:each) { stop_all_commands } it do with_environment 'REALLY_LONG_LONG_VARIABLE' => 'a' do expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'a' end end # Has no effect here, is not in block and not a command `run` it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq 'a' } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/environment/set_environment_variable.feature000066400000000000000000000264511267252361200272600ustar00rootroot00000000000000Feature: Set environment variable via API-method It is quite handy to modify the environment of a process. To make this possible, `aruba` provides several methods. One of these is `#set_environment_variable`. Using this sets the value of a non-existing variable and overwrites an existing value. Each variable name and each value is converted to a string. Otherwise `ruby` would complain about an invalid argument. To make use of a variable you can either use `#run` and the like or `#with_environment`. Besides setting a variable globally, you can set one for a block of code only using `#with_environment`. Background: Given I use the fixture "cli-app" Scenario: Non-existing variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '1' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=1' } end """ When I run `rspec` Then the specs should all pass Scenario: Existing variable set from within the test Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '1' } before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '2' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=2' } end """ When I run `rspec` Then the specs should all pass Scenario: Existing variable set by some outer parent process Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = '1' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '2' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'REALLY_LONG_LONG_VARIABLE=2' } it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '1' } end """ When I run `rspec` Then the specs should all pass Scenario: Set variable via ENV Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Environment command', :type => :aruba do before(:each) { ENV['REALLY_LONG_LONG_VARIABLE'] = '2' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'REALLY_LONG_LONG_VARIABLE=2' } end """ When I run `rspec` Then the specs should all pass Scenario: Existing variable set in before block in RSpec Setting environment variables with `#set_environment_variable('VAR', 'value')` takes precedence before setting variables with `ENV['VAR'] = 'value'`. Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '1' } before(:each) { ENV['REALLY_LONG_LONG_VARIABLE'] = '2' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'REALLY_LONG_LONG_VARIABLE=1' } end """ When I run `rspec` Then the specs should all pass Scenario: Run some ruby code in code with previously set environment The `#with_environment`-block makes the change environment temporary avaiable for the code run within the block. Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = '1' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '2' } before(:each) { run('env') } before(:each) { stop_all_commands } it do with_environment do expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '2' end end it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '1' } end """ When I run `rspec` Then the specs should all pass Scenario: Run some ruby code with local environment If you need to set some environment variables only for the given block. Pass it an `Hash` containing the environment variables. Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = '1' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '2' } before(:each) { run('env') } before(:each) { stop_all_commands } it do with_environment 'REALLY_LONG_LONG_VARIABLE' => '3' do expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '3' end end it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '1' } end """ When I run `rspec` Then the specs should all pass Scenario: Nested setup with rspec It doesn't matter if you define an environment variable in some outer scope, when you are using `RSpec`. Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '1' } describe 'Method XX' do before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=1' } end describe 'Method YY' do before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', '2' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=2' } end end """ When I run `rspec` Then the specs should all pass Scenario: When an error occures the ENV is not polluted Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['REALLY_LONG_LONG_VARIABLE'] = '1' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '2' } before(:each) { run('env') } before(:each) { stop_all_commands } it do begin with_environment 'REALLY_LONG_LONG_VARIABLE' => '3' do fail end rescue StandardError end expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '1' end it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '1' } end """ When I run `rspec` Then the specs should all pass Scenario: Run some ruby code with nested environment blocks It is possible to use a `#with_environment`-block with a `#with_environment`-block. Each previously set variable is available with the most inner block. Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['LONG_LONG_VARIABLE'] = '1' ENV['REALLY_LONG_LONG_VARIABLE'] = '1' RSpec.describe 'Environment command', :type => :aruba do it do with_environment 'REALLY_LONG_LONG_VARIABLE' => 2 do with_environment 'LONG_LONG_VARIABLE' => 3 do expect(ENV['LONG_LONG_VARIABLE']).to eq '3' expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '2' end end end it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '1' } end """ When I run `rspec` Then the specs should all pass Scenario: Re-use `#with_environment` for multiple `RSpec`-`it`-blocks If you chose to run wrap examples via `RSpec`'s `around`-hook, make sure you use `before(:context) {}` instead of `before(:each)` to set an environment variable. Only then the `before`-hook is run before the `around`-hook is run. Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Environment command', :type => :aruba do # Please mind :context. This is run BEFORE the `around`-hook before(:context) { set_environment_variable 'REALLY_LONG_LONG_VARIABLE', '1' } context 'when no arguments are given' do around(:each) do |example| with_environment do example.run end end it { expect(ENV['REALLY_LONG_LONG_VARIABLE']).to eq '1' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'REALLY_LONG_LONG_VARIABLE=1' } end context 'when arguments given' do around(:each) do |example| with_environment 'LONG_LONG_VARIABLE' => 2 do example.run end end it { expect(ENV['LONG_LONG_VARIABLE']).to eq '2' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'REALLY_LONG_LONG_VARIABLE=1' } end end """ When I run `rspec` Then the specs should all pass @unsupported-on-platform-windows Scenario: Mixed-Case variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'long_LONG_VARIABLE', '1' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'long_LONG_VARIABLE=1' } end """ When I run `rspec` Then the specs should all pass @unsupported-on-platform-unix @unsupported-on-platform-mac Scenario: Mixed-Case variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'long_LONG_VARIABLE', '1' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=1' } end """ When I run `rspec` Then the specs should all pass Scenario: External ruby file / ruby gem modifying ENV There are some Rubygems around which need to modify ENV['NODE_PATH'] like [`ruby-stylus`](https://github.com/forgecrafted/ruby-stylus/blob/e7293362dc8cbf550f7c317d721ba6b9087e8833/lib/stylus.rb#L168). This is supported by aruba as well. Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' $LOAD_PATH << File.expand_path('../../lib', __FILE__) RSpec.describe 'Environment command', :type => :aruba do before(:each) do require 'my_library' end before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=1' } end """ And a file named "lib/my_library.rb" with: """ ENV['LONG_LONG_VARIABLE'] = '1' """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/000077500000000000000000000000001267252361200204275ustar00rootroot00000000000000ruby-aruba-0.14.1/features/api/filesystem/cd.feature000066400000000000000000000113511267252361200223730ustar00rootroot00000000000000Feature: Change current working directory If you need to run some code in a different directory you can use the `cd` command. It comes in two flavors: \* First can simply use `cd 'some-dir'` \* Second can use the block notation `cd('some-dir') { Dir.getwd }` If you chose to use the latter one, the result of your block is returned. The current working directory is only changed for the code inside the block - it's use is side effect free. Background: Given I use a fixture named "cli-app" Scenario: Existing directory Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'cd to directory', :type => :aruba do before(:each) do create_directory 'new_dir.d' cd 'new_dir.d' end before(:each) { run_simple 'pwd' } it { expect(last_command_started.output).to include 'new_dir.d' } end """ When I run `rspec` Then the specs should all pass Scenario: Non-Existing directory Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'cd to directory', :type => :aruba do before(:each) { cd 'new_dir.d' } before(:each) { run_simple 'pwd' } it { expect(last_command_started.output).to include 'new_dir.d' } it { expect(last_command_started).to be_executed_in_time } end """ When I run `rspec` Then the specs should not pass Scenario: With block in it-block Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'cd to directory', :type => :aruba do before(:each) do create_directory 'new_dir.d/subdir.d' end it do cd('new_dir.d/subdir.d') { expect(Dir.getwd).to include 'new_dir.d/subdir.d' } end end """ When I run `rspec` Then the specs should all pass Scenario: With block in before-block Running `cd` with a block does not change: \* The current directory - `Dir.getwd` \* Aruba's current directory Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'cd to directory', :type => :aruba do before(:each) do create_directory 'new_dir.d/subdir.d' end before :each do cd('new_dir.d/subdir.d') do # you code end end it { expect(Dir.getwd).not_to include 'new_dir.d/subdir.d' } it { expect(expand_path('.')).not_to include 'new_dir.d/subdir.d' } end """ When I run `rspec` Then the specs should all pass Scenario: The result of the block is returned If you need to run some code in a different directory, you can also use the block-notation of `cd`. Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'cd to directory', :type => :aruba do before(:each) do create_directory 'new_dir.d/subdir.d' end before :each do @my_output = cd('new_dir.d/subdir.d') { Dir.getwd } end it { expect(@my_output).to include 'new_dir.d/subdir.d' } end """ When I run `rspec` Then the specs should all pass Scenario: It changes the PWD- and OLDPWD-ENV-variable for a given block If you need to run some code in a different directory, you can also use the block-notation of `cd`. Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'cd to directory', :type => :aruba do before(:each) do create_directory 'new_dir.d' end before :each do cd('new_dir.d/') do @pwd = ENV['PWD'] @oldpwd = ENV['OLDPWD'] end end it { expect(@pwd).to end_with 'new_dir.d' } it { expect(@oldpwd).to end_with 'cli-app' } end """ When I run `rspec` Then the specs should all pass Scenario: Nested cd calls If you need to run some code in a different directory, you can also use the block-notation of `cd`. Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'cd to directory', :type => :aruba do before(:each) do create_directory 'new_dir.d/subdir.d' end before :each do cd('new_dir.d') do @oldpwd_1 = ENV['OLDPWD'] @pwd_1 = ENV['PWD'] cd('subdir.d') do @oldpwd_2 = ENV['OLDPWD'] @pwd_2 = ENV['PWD'] end end end it { expect(@oldpwd_1).to be_end_with 'cli-app' } it { expect(@pwd_1).to be_end_with 'new_dir.d' } it { expect(@oldpwd_2).to be_end_with 'new_dir.d' } it { expect(@pwd_2).to be_end_with 'subdir.d' } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/create_directory.feature000066400000000000000000000025711267252361200253400ustar00rootroot00000000000000Feature: Create Directory Use the `#create_directory`-method to create a directory within `aruba`'s working directory. ```ruby require 'spec_helper' RSpec.configure do |config| config.include Aruba::Api end RSpec.describe 'Create directory' do let(:directory) { 'dir.d' } before(:each) { create_directory(directory) } it { expect(directory).to be_an_existing_directory } end ``` Background: Given I use a fixture named "cli-app" Scenario: New directory Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Create directory', :type => :aruba do let(:directory) { 'dir.d' } before(:each) { create_directory(directory) } it { expect(directory).to be_an_existing_directory } end """ When I run `rspec` Then the specs should all pass Scenario: Existing directory It does not complain if a directory already exists. Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Create directory', :type => :aruba do let(:directory) { 'dir.d' } before(:each) { create_directory(directory) } before(:each) { create_directory(directory) } it { expect(directory).to be_an_existing_directory } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/disk_usage.feature000066400000000000000000000103061267252361200241220ustar00rootroot00000000000000@unsupported-on-ruby-older-19 Feature: Report disk usage Sometimes you need to check, what amount of disk space a file consumes. We do NOT support "directories" with `#disk_usage`. This does not work reliably over different systems. Here can help `'#disk_usage`. But be careful, by default it uses a block size of "512" (physical block size) to calculate the usage. You may need to adjust this by using `Aruba.configure { |config| config.physical_block_size = 4_096 }`. Don't get confused, if you check the block size by using `File::Stat` (in ruby). It reports the block size of your filesystem, which can be "4_096" for example. We're gonna use the (correct) IEC-notation (https://en.wikipedia.org/wiki/Binary_prefix) here: \* kilo => kibi \* mega => mebi \* giga => gibi Background: Given I use a fixture named "cli-app" Scenario: Show disk usage for file Given a file named "spec/disk_usage_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'disk usage', :type => :aruba do let(:file) { 'file.txt' } before(:each) do write_file file, 'a' end let(:size_of_single_block) { File::Stat.new(expand_path(file)).blksize } it { expect(disk_usage(file)).to eq size_of_single_block } end """ When I run `rspec` Then the specs should all pass Scenario: Show disk usage for multiple files `#disk_usage` creates the sum of all given objects' sizes. Given a file named "spec/disk_usage_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'disk usage', :type => :aruba do let(:file1) { 'file1.txt' } let(:file2) { 'file2.txt' } before(:each) do write_file file1, 'a' write_file file2, 'a' end let(:size_of_single_block) { File::Stat.new(expand_path(file1)).blksize } it { expect(disk_usage(file1, file2)).to eq size_of_single_block * 2 } it { expect(disk_usage([file1, file2])).to eq size_of_single_block * 2 } end """ When I run `rspec` Then the specs should all pass Scenario: Convert reported disk usage to KibiByte Given a file named "spec/disk_usage_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'disk usage', :type => :aruba do let(:file) { 'file.txt' } before(:each) do write_file file, 'a' end let(:converted_size) { File::Stat.new(expand_path(file)).blksize.to_f / 1_024 } it { expect(disk_usage(file).to_kibi_byte).to eq converted_size } end """ When I run `rspec` Then the specs should all pass Scenario: Convert reported disk usage to MebiByte Given a file named "spec/disk_usage_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'disk usage', :type => :aruba do let(:file) { 'file.txt' } before(:each) do write_file file, 'a' end let(:converted_size) { File::Stat.new(expand_path(file)).blksize.to_f / 1_024 / 1024 } it { expect(disk_usage(file).to_mebi_byte).to eq converted_size } end """ When I run `rspec` Then the specs should all pass Scenario: Convert reported disk usage to GibiByte Given a file named "spec/disk_usage_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'disk usage', :type => :aruba do let(:file) { 'file.txt' } before(:each) do write_file file, 'a' end let(:converted_size) { File::Stat.new(expand_path(file)).blksize.to_f / 1_024 / 1_024 / 1_024 } it { expect(disk_usage(file).to_gibi_byte).to eq converted_size } end """ When I run `rspec` Then the specs should all pass Scenario: Compare two repored disk usages Given a file named "spec/disk_usage_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'disk usage', :type => :aruba do let(:file1) { 'file1.txt' } let(:file2) { 'file2.txt' } before(:each) do write_file file1, 'a' * 10_000 write_file file2, 'a' end before :each do @size1 = disk_usage(file1) @size2 = disk_usage(file2) end it { expect(@size1).to be > @size2 } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/does_exist.feature000066400000000000000000000032431267252361200241540ustar00rootroot00000000000000Feature: Check existence of files and directories Use the `#exist?` to check if a path exists within `aruba`'s working directory. , May also want to look for `#file?` or `#directory?` for some more specific tests. ```ruby require 'spec_helper' RSpec.configure do |config| config.include Aruba::Api end RSpec.describe 'Check if directory and file exist' do let(:directory) { 'dir.d' } let(:file) { 'file.txt' } before(:each) { create_directory(directory) } before(:each) { touch(file) } it { expect(exist?(directory)).to be true } it { expect(exist?(file)).to be true } end ``` Background: Given I use a fixture named "cli-app" Scenario: Is file or directory and exists Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory and file exist', :type => :aruba do let(:directory) { 'dir.d' } let(:file) { 'file.txt' } before(:each) { create_directory(directory) } before(:each) { touch(file) } it { expect(exist?(directory)).to be true } it { expect(exist?(file)).to be true } end """ When I run `rspec` Then the specs should all pass Scenario: Is file or directory and does not exist Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory and file exist', :type => :aruba do let(:directory) { 'dir.d' } let(:file) { 'file.txt' } it { expect(exist?(directory)).to be false } it { expect(exist?(file)).to be false } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/fixtures.feature000066400000000000000000000062351267252361200236630ustar00rootroot00000000000000Feature: Use fixtures in your tests Sometimes your tests need existing files to work - e.g binary data files you cannot create programmatically. Since `aruba` >= 0.6.3 includes some basic support for fixtures. All you need to do is the following: 1. Create a `fixtures`-directory 2. Create fixture files in this directory Background: Given I use a fixture named "cli-app" Scenario: Use a fixture for your tests Given a file named "features/fixtures.feature" with: """ Feature: Fixture Scenario: Fixture Given a file named "fixtures_spec.rb" with: \"\"\" RSpec.describe 'My Feature' do describe '#read_music_file' do context 'when the file exists' do before :each { copy '%/song.mp3', 'file.mp3' } it { expect('file.mp3').to be_an_existing_file } end end end \"\"\" """ And a directory named "fixtures" And an empty file named "fixtures/fixtures-app/test.txt" When I run `rspec` Then the specs should all pass Scenario: Use a fixture for your tests in test/ Given a file named "features/fixtures.feature" with: """ Feature: Fixture Scenario: Fixture Given a file named "fixtures_spec.rb" with: \"\"\" RSpec.describe 'My Feature' do describe '#read_music_file' do context 'when the file exists' do before :each { copy '%/song.mp3', 'file.mp3' } it { expect('file.mp3').to be_an_existing_file } end end end \"\"\" """ And a directory named "test/fixtures" And an empty file named "test/fixtures/fixtures-app/test.txt" When I run `rspec` Then the specs should all pass Scenario: Use a fixture for your tests in spec/ Given a file named "features/fixtures.feature" with: """ Feature: Fixture Scenario: Fixture Given a file named "fixtures_spec.rb" with: \"\"\" RSpec.describe 'My Feature' do describe '#read_music_file' do context 'when the file exists' do before :each { copy '%/song.mp3', 'file.mp3' } it { expect('file.mp3').to be_an_existing_file } end end end \"\"\" """ And a directory named "spec/fixtures" And an empty file named "spec/fixtures/fixtures-app/test.txt" When I run `rspec` Then the specs should all pass Scenario: Use a fixture for your tests in features/ Given a file named "features/fixtures.feature" with: """ Feature: Fixture Scenario: Fixture Given a file named "fixtures_spec.rb" with: \"\"\" RSpec.describe 'My Feature' do describe '#read_music_file' do context 'when the file exists' do before :each { copy '%/song.mp3', 'file.mp3' } it { expect('file.mp3').to be_an_existing_file } end end end \"\"\" """ And a directory named "features/fixtures" And an empty file named "features/fixtures/fixtures-app/test.txt" When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/is_absolute.feature000066400000000000000000000022471267252361200243220ustar00rootroot00000000000000Feature: Check if path is absolute Use the `#absolute?`-method to check if a path is an absolute path. ```ruby require 'spec_helper' RSpec.configure do |config| config.include Aruba::Api end RSpec.describe 'Check if directory or file is absolute' do let(:path) { '/path/to/file.txt' } it { expect(absolute?(path)).to be true } end ``` Background: Given I use a fixture named "cli-app" Scenario: Is path absolute Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory or file is absolute', :type => :aruba do let(:path) { '/path/to/file.txt' } it { expect(absolute?(path)).to be true } end """ When I run `rspec` Then the specs should all pass Scenario: Path should be absolute, but it's relative Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory or file is absolute', :type => :aruba do let(:path) { 'file.txt' } it { expect(absolute?(path)).to be false } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/is_directory.feature000066400000000000000000000025221267252361200245040ustar00rootroot00000000000000Feature: Check existence of directories Use the `#directory?` to check if a path is a directory and exists within `aruba`'s working directory. ```ruby require 'spec_helper' RSpec.configure do |config| config.include Aruba::Api end RSpec.describe 'Check if directory and file exist' do let(:directory) { 'dir.d' } before(:each) { create_directory(directory) } it { expect(directory?(directory)).to be true } end ``` Background: Given I use a fixture named "cli-app" Scenario: Is directory and exist Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory and file exist', :type => :aruba do let(:directory) { 'dir.d' } before(:each) { create_directory(directory) } it { expect(directory?(directory)).to be true } end """ When I run `rspec` Then the specs should all pass Scenario: Is file, but should be directory and exist Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory and file exist', :type => :aruba do let(:file) { 'file.txt' } before(:each) { touch(file) } it { expect(directory?(file)).to be false } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/is_file.feature000066400000000000000000000024301267252361200234150ustar00rootroot00000000000000Feature: Check existence of files Use the `#file?` to check if a path is a file and exists within `aruba`'s working directory. ```ruby require 'spec_helper' RSpec.configure do |config| config.include Aruba::Api end RSpec.describe 'Check if directory and file exist' do let(:file) { 'file.txt' } before(:each) { touch(file) } it { expect(file?(file)).to be true } end ``` Background: Given I use a fixture named "cli-app" Scenario: Is file and exist Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory and file exist', :type => :aruba do let(:file) { 'file.txt' } before(:each) { touch(file) } it { expect(file?(file)).to be true } end """ When I run `rspec` Then the specs should all pass Scenario: Is directory, but should be file and exist Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory and file exist', :type => :aruba do let(:directory) { 'dir.d' } before(:each) { create_directory(directory) } it { expect(file?(directory)).to be false } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/is_relative.feature000066400000000000000000000022471267252361200243170ustar00rootroot00000000000000Feature: Check if path is relative Use the `#relative?`-method to check if a path is an relative path. ```ruby require 'spec_helper' RSpec.configure do |config| config.include Aruba::Api end RSpec.describe 'Check if directory or file is relative' do let(:path) { '/path/to/file.txt' } it { expect(relative?(path)).to be true } end ``` Background: Given I use a fixture named "cli-app" Scenario: Is path relative Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory or file is relative', :type => :aruba do let(:path) { 'file.txt' } it { expect(relative?(path)).to be true } end """ When I run `rspec` Then the specs should all pass Scenario: Path should be relative, but it's relative Given a file named "spec/create_directory_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Check if directory or file is relative', :type => :aruba do let(:path) { '/path/to/file.txt' } it { expect(relative?(path)).to be false } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/filesystem/move.feature000066400000000000000000000064031267252361200227550ustar00rootroot00000000000000Feature: Move file/directory If you need to move some files/directories you can use the `#move`-method command. If multiple arguments are given, the last one needs to be a directory. Background: Given I use a fixture named "cli-app" Scenario: Non-existing destination Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Move', :type => :aruba do let(:old_location) { 'old_dir.d' } let(:new_location) { 'new_dir.d' } before(:each) do create_directory old_location move old_location, new_location end it { expect(new_location).to be_an_existing_directory } end """ When I run `rspec` Then the specs should all pass Scenario: Existing destination Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Move', :type => :aruba do let(:old_location) { 'old_dir.d' } let(:new_location) { 'new_dir.d' } before(:each) do create_directory old_location create_directory new_location move old_location, new_location end it { expect(File.join(new_location, old_location)).to be_an_existing_directory } end """ When I run `rspec` Then the specs should all pass Scenario: Source is fixture path Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Move', :type => :aruba do let(:old_location) { '%/old_dir.d' } let(:new_location) { 'new_dir.d' } it { expect { move old_location, new_location }.to raise_error ArgumentError, /fixture/ } end """ When I run `rspec` Then the specs should all pass Scenario: Destination is fixture path Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Move', :type => :aruba do let(:old_location) { 'old_dir.d' } let(:new_location) { '%/new_dir.d' } it { expect { move old_location, new_location }.to raise_error ArgumentError, /fixture/ } end """ When I run `rspec` Then the specs should all pass Scenario: Multiple sources and destination is directory Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Move', :type => :aruba do let(:old_location) { %w(old_dir1.d old_dir2.d) } let(:new_location) { 'new_dir.d' } before :each do old_location.each { |l| create_directory l } move old_location, new_location end it { expect(old_location.map { |l| File.join(new_location, l) }).to all be_an_existing_directory } end """ When I run `rspec` Then the specs should all pass Scenario: Multiple sources and destination is file Given a file named "spec/cd_spec.rb" with: """ruby require 'spec_helper' RSpec.describe 'Move', :type => :aruba do let(:old_location) { %w(old_dir1.d old_dir2.d) } let(:new_location) { 'new_file.txt' } before :each do old_location.each { |l| create_directory l } touch new_location end it { expect { move old_location, new_location }.to raise_error ArgumentError, /Multiple sources/ } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/text/000077500000000000000000000000001267252361200172275ustar00rootroot00000000000000ruby-aruba-0.14.1/features/api/text/extract_text.feature000066400000000000000000000047201267252361200233250ustar00rootroot00000000000000Feature: Extract text from output If you need to strip down some command output to plain text, you can use the `#extract_text`-method for this. Background: Given I use a fixture named "cli-app" Scenario: Output contains ansi escape codes prefixed by \e Given an executable named "bin/cli" with: """ #!/bin/bash echo -n "\e[31mText" """ And a file named "spec/extract_text_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains ansi escape codes prefixed by \033 Given an executable named "bin/cli" with: """ #!/bin/bash echo -n "\033[31mText" """ And a file named "spec/extract_text_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" } end """ When I run `rspec` Then the specs should all pass # Scenario: Output contains ansi escape code \016 # Given an executable named "bin/cli" with: # """ # #!/bin/bash # echo -n "\016Text" # """ # And a file named "spec/extract_text_spec.rb" with: # """ # require 'spec_helper' # # RSpec.describe 'Run command', :type => :aruba do # before(:each) { run('cli') } # before(:each) { stop_all_commands } # # it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" } # end # """ # When I run `rspec` # Then the specs should all pass # Scenario: Output contains ansi escape code \017 # Given an executable named "bin/cli" with: # """ # #!/bin/bash # echo -n "\017Text" # """ # And a file named "spec/extract_text_spec.rb" with: # """ # require 'spec_helper' # # RSpec.describe 'Run command', :type => :aruba do # before(:each) { run('cli') } # before(:each) { stop_all_commands } # # it { expect(extract_text(unescape_text(last_command.output))).to eq "Text" } # end # """ # When I run `rspec` # Then the specs should all pass ruby-aruba-0.14.1/features/api/text/replace_variables.feature000066400000000000000000000024471267252361200242560ustar00rootroot00000000000000@experimental Feature: Replace variables There are use cases where you need access to some information from aruba in your command line. The `#replace_variables`-method makes this information available. Please note, this feature is experimental for now. The implementation of this feature and the name of variables may change without further notice. Background: Given I use a fixture named "cli-app" Scenario: PID of last command started Given an executable named "bin/cli" with: """ #!/bin/bash exit 0 """ And a file named "spec/replace_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(replace_variables('')).to eq last_command_started.pid.to_s } end """ When I run `rspec` Then the specs should all pass Scenario: No last command started Given a file named "spec/replace_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do it { expect { replace_variables('') }.to raise_error Aruba::NoCommandHasBeenStartedError } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/api/text/sanitize_text.feature000066400000000000000000000142041267252361200234770ustar00rootroot00000000000000Feature: Sanitize text from output If have got some text include \n, \t and the like and need them to become special characters again and also want the text to be stripped down to bare text, you can use the `#sanitize_text`-method for this. Background: Given I use a fixture named "cli-app" Scenario: Output contains \n Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\ntext' """ And a file named "spec/sanitize_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(sanitize_text(last_command_started.output)).to eq "text\ntext" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \e Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\etext' """ And a file named "spec/sanitize_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(sanitize_text(last_command_started.output)).to eq "texttext" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \" Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\"text' """ And a file named "spec/sanitize_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(sanitize_text(last_command_started.output)).to eq "text\"text" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \033 Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\033text' """ And a file named "spec/sanitize_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(sanitize_text(last_command_started.output)).to eq "texttext" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \017 Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\017text' """ And a file named "spec/sanitize_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(sanitize_text(last_command_started.output)).to eq "texttext" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \016 Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\016text' """ And a file named "spec/sanitize_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(sanitize_text(last_command_started.output)).to eq "texttext" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains ansi escape codes prefixed by \e Given an executable named "bin/cli" with: """ #!/bin/bash echo -n "\e[31mText" """ And a file named "spec/sanitize_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(sanitize_text(last_command_started.output)).to eq "Text" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains ansi escape codes prefixed by \033 Given an executable named "bin/cli" with: """ #!/bin/bash echo -n "\033[31mText" """ And a file named "spec/sanitize_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(sanitize_text(last_command_started.output)).to eq "Text" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains ansi escape codes prefixed by \e, but removable is disabled by configuration Given an executable named "bin/cli" with: """ #!/bin/bash echo -n "\e[31mText" """ And a file named "spec/sanitize_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba, :remove_ansi_escape_sequences => false, :keep_ansi => true do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(sanitize_text(last_command_started.output)).to eq "\e[31mText" } end """ When I run `rspec` Then the specs should all pass # Scenario: Output contains ansi escape code \016 # Given an executable named "bin/cli" with: # """ # #!/bin/bash # echo -n "\016Text" # """ # And a file named "spec/sanitize_spec.rb" with: # """ # require 'spec_helper' # # RSpec.describe 'Run command', :type => :aruba do # before(:each) { run('cli') } # before(:each) { stop_all_commands } # # it { expect(sanitize_text(last_command_started.output)).to eq "Text" } # end # """ # When I run `rspec` # Then the specs should all pass # Scenario: Output contains ansi escape code \017 # Given an executable named "bin/cli" with: # """ # #!/bin/bash # echo -n "\017Text" # """ # And a file named "spec/sanitize_spec.rb" with: # """ # require 'spec_helper' # # RSpec.describe 'Run command', :type => :aruba do # before(:each) { run('cli') } # before(:each) { stop_all_commands } # # it { expect(sanitize_text(last_command_started.output)).to eq "Text" } # end # """ # When I run `rspec` # Then the specs should all pass ruby-aruba-0.14.1/features/api/text/unescape_text.feature000066400000000000000000000063451267252361200234630ustar00rootroot00000000000000Feature: Unescape special characters in text If have got some text include \n, \t and the like and need them to become special characters again, you can use the `#unescape_text`-method for this. Background: Given I use a fixture named "cli-app" Scenario: Output contains \n Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\ntext' """ And a file named "spec/unescape_text_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(unescape_text(last_command.output)).to eq "text\ntext" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \e Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\etext' """ And a file named "spec/unescape_text_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(unescape_text(last_command.output)).to eq "texttext" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \" Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\"text' """ And a file named "spec/unescape_text_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(unescape_text(last_command.output)).to eq "text\"text" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \033 Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\033text' """ And a file named "spec/unescape_text_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(unescape_text(last_command.output)).to eq "texttext" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \017 Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\017text' """ And a file named "spec/unescape_text_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(unescape_text(last_command.output)).to eq "texttext" } end """ When I run `rspec` Then the specs should all pass Scenario: Output contains \016 Given an executable named "bin/cli" with: """ #!/bin/bash echo -n 'text\016text' """ And a file named "spec/unescape_text_spec.rb" with: """ require 'spec_helper' RSpec.describe 'Run command', :type => :aruba do before(:each) { run('cli') } before(:each) { stop_all_commands } it { expect(unescape_text(last_command.output)).to eq "texttext" } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/cli/000077500000000000000000000000001267252361200162415ustar00rootroot00000000000000ruby-aruba-0.14.1/features/cli/console.feature000066400000000000000000000022071267252361200212610ustar00rootroot00000000000000Feature: Aruba Console Background: Given a mocked home directory Scenario: Start console Given I run `aruba console` interactively When I close the stdin stream Then the output should contain: """ aruba:001:0> """ @unsupported-on-platform-java Scenario: Show help Given I run `aruba console` interactively And I type "aruba_help" When I close the stdin stream Then the output should contain: """ Version: """ And the output should contain: """ Issue Tracker: """ And the output should contain: """ Documentation: """ @unsupported-on-platform-java Scenario: Show methods Given I run `aruba console` interactively And I type "aruba_methods" When I close the stdin stream Then the output should contain: """ Methods: """ And the output should contain: """ * setup_aruba """ @unsupported-on-platform-java Scenario: Has history Given I run `aruba console` interactively And I type "aruba_methods" And I type "exit" When I close the stdin stream Then the file "~/.aruba_history" should exist ruby-aruba-0.14.1/features/cli/init.feature000066400000000000000000000037471267252361200205740ustar00rootroot00000000000000Feature: Initialize project with aruba To add `aruba` to your project you can use the `aruba init`-command. Background: Given I use the fixture "empty-app" Scenario: Create files for RSpec When I successfully run `aruba init --test-framework rspec` Then the following files should exist: | spec/spec_helper.rb | And the file "spec/support/aruba.rb" should contain: """ require 'aruba/rspec' """ And the file "Gemfile" should contain: """ gem 'aruba' """ When I successfully run `rspec` Then the output should contain: """ 0 examples, 0 failures """ Scenario: Create files for Cucumber When I successfully run `aruba init --test-framework cucumber` Then the file "features/support/aruba.rb" should contain: """ require 'aruba/cucumber' """ And the file "Gemfile" should contain: """ gem 'aruba' """ When I successfully run `cucumber` Then the output should contain: """ 0 scenarios 0 steps """ Scenario: Create files for Cucumber (Default) When I successfully run `aruba init` Then the file "features/support/aruba.rb" should contain: """ require 'aruba/cucumber' """ And the file "Gemfile" should contain: """ gem 'aruba' """ When I successfully run `cucumber` Then the output should contain: """ 0 scenarios 0 steps """ Scenario: Create files for Minitest When I successfully run `aruba init --test-framework minitest` Then the following files should exist: | test/test_helper.rb | And the file "Gemfile" should contain: """ gem 'aruba' """ When I successfully run `ruby -Ilib:test test/use_aruba_with_minitest.rb` Then the output should contain: """ 0 runs, 0 assertions, 0 failures, 0 errors, 0 skips """ Scenario: Unknown Test Framework When I run `aruba init --test-framework unknown` Then the output should contain: """ got unknown """ ruby-aruba-0.14.1/features/configuration/000077500000000000000000000000001267252361200203415ustar00rootroot00000000000000ruby-aruba-0.14.1/features/configuration/activate_announcer_on_command_failure.feature000066400000000000000000000020741267252361200314720ustar00rootroot00000000000000Feature: Configure announcer activation on command failure As a developer I want to configure which announcers should get activated on command failure In order to understand what caused a command to fail Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts %(The default value is "#{config.activate_announcer_on_command_failure.inspect}") end """ When I successfully run `cucumber` Then the output should contain: """ruby The default value is "[]" """ Scenario: Modify value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| config.activate_announcer_on_command_failure = [:foo, :bar] end Aruba.configure do |config| puts %(The value is "#{config.activate_announcer_on_command_failure.inspect}") end """ Then I successfully run `cucumber` Then the output should contain: """ The value is "[:foo, :bar]" """ ruby-aruba-0.14.1/features/configuration/command_runtime_environment.feature000066400000000000000000000072351267252361200275320ustar00rootroot00000000000000Feature: Define default process environment Say you want to have a default set of environment variables, then use this code. ~~~ruby Aruba.configure do |config| config.command_runtime_environment = { 'MY_VARIABLE' => 'x' } end ~~~ This can be changed via `#set_environment_variable`, `#append_environment_variable`, `#delete_environment_variable` or `#prepend_environment_variable`. Background: Given I use the fixture "cli-app" Scenario: Overwrite existing variable with new default value Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['LONG_LONG_VARIABLE'] = 'y' Aruba.configure do |config| config.command_runtime_environment = { 'LONG_LONG_VARIABLE' => 'x' } end RSpec.describe 'Environment command', :type => :aruba do before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=x' } end """ When I run `rspec` Then the specs should all pass Scenario: Overwrite default value for variable Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['LONG_LONG_VARIABLE'] = 'y' Aruba.configure do |config| config.command_runtime_environment = { 'LONG_LONG_VARIABLE' => 'x' } end RSpec.describe 'Environment command', :type => :aruba do before(:each) { set_environment_variable 'LONG_LONG_VARIABLE', 'z' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=z' } end """ When I run `rspec` Then the specs should all pass Scenario: Append value to default value Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['LONG_LONG_VARIABLE'] = 'y' Aruba.configure do |config| config.command_runtime_environment = { 'LONG_LONG_VARIABLE' => 'x' } end RSpec.describe 'Environment command', :type => :aruba do before(:each) { append_environment_variable 'LONG_LONG_VARIABLE', 'z' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=xz' } end """ When I run `rspec` Then the specs should all pass Scenario: Prepend value Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['LONG_LONG_VARIABLE'] = 'y' Aruba.configure do |config| config.command_runtime_environment = { 'LONG_LONG_VARIABLE' => 'x' } end RSpec.describe 'Environment command', :type => :aruba do before(:each) { prepend_environment_variable 'LONG_LONG_VARIABLE', 'z' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).to include 'LONG_LONG_VARIABLE=zx' } end """ When I run `rspec` Then the specs should all pass Scenario: Remove variable from default set of variables Given a file named "spec/environment_spec.rb" with: """ruby require 'spec_helper' ENV['LONG_LONG_VARIABLE'] = 'y' Aruba.configure do |config| config.command_runtime_environment = { 'LONG_LONG_VARIABLE' => 'x' } end RSpec.describe 'Environment command', :type => :aruba do before(:each) { delete_environment_variable 'LONG_LONG_VARIABLE' } before(:each) { run('env') } before(:each) { stop_all_commands } it { expect(last_command_started.output).not_to include 'LONG_LONG_VARIABLE' } end """ When I run `rspec` Then the specs should all pass ruby-aruba-0.14.1/features/configuration/console_history_file.feature000066400000000000000000000017651267252361200261510ustar00rootroot00000000000000Feature: Configure the aruba console history file As a developer I want to configure the history file of aruba console In order to have a better isolation of tests Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ Aruba.configure do |config| puts %(The default value is "#{config.console_history_file}") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "~/.aruba_history" """ Scenario: Set some value Given a file named "features/support/aruba.rb" with: """ Aruba.configure do |config| config.console_history_file = '~/.config/aruba/history.txt' end Aruba.configure do |config| puts %(The value is "#{config.console_history_file}") end """ Then I successfully run `cucumber` Then the output should contain: """ The value is "~/.config/aruba/history.txt" """ ruby-aruba-0.14.1/features/configuration/exit_timeout.feature000066400000000000000000000023551267252361200244420ustar00rootroot00000000000000Feature: Configure timeout for command execution As a developer I want to configure the timeout when executing a command In order to support some longer running commands Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts %(The default value is "#{config.exit_timeout}") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "15" """ Scenario: Modify value Given an executable named "bin/cli" with: """bash #!/bin/bash sleep 1 """ And a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| config.exit_timeout = 2 end """ And the default feature-test Then I successfully run `cucumber` Scenario: Fails if takes longer Given an executable named "bin/cli" with: """ruby #!/bin/bash sleep 2 """ And a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| config.exit_timeout = 1 end """ And the default feature-test Then I run `cucumber` And the exit status should be 1 ruby-aruba-0.14.1/features/configuration/fixtures_directories.feature000066400000000000000000000021001267252361200261540ustar00rootroot00000000000000Feature: Configure directory where to look for fixtures As a developer I want to configure the directory where aruba looks for fixtures In order to use them in my tests Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts %(The default value is "%w(#{config.fixtures_directories.join(" ")})") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "%w(features/fixtures spec/fixtures test/fixtures fixtures)" """ Scenario: Modify value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| config.fixtures_directories = %w(spec/fixtures) end Aruba.configure do |config| puts %(The default value is "%w(#{config.fixtures_directories.join(" ")})") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "%w(spec/fixtures)" """ ruby-aruba-0.14.1/features/configuration/fixtures_path_prefix.feature000066400000000000000000000010301267252361200261520ustar00rootroot00000000000000Feature: Use fixtures path prefix of aruba As a developer I want to use the fixtures path prefix in aruba In some API-method for using the fixtures path Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts "The prefix is \"#{config.fixtures_path_prefix}\"." end """ When I successfully run `cucumber` Then the output should contain: """ The prefix is "%". """ ruby-aruba-0.14.1/features/configuration/home_directory.feature000066400000000000000000000043141267252361200247340ustar00rootroot00000000000000Feature: Configure the home directory to be used with aruba As a developer I want to configure the home directory In order to have a better isolation of tests Be careful to set the HOME-variable aka `config.home_directory` to something else than `/tmp/aruba`. This is a dance with the devil and violates the isolation of your test suite. Thus will be not supported from aruba as of 1.0.0. Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts %(The default value is "#{config.home_directory}") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "/home/ """ Scenario: Set to current working directory Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| # use current working directory config.home_directory = '.' end Aruba.configure do |config| puts %(The default value is "#{config.home_directory}") end """ Then I successfully run `cucumber` Then the output should contain: """ The default value is "." """ Scenario: Set to aruba's working directory Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| # Use aruba working directory config.home_directory = File.join(config.root_directory, config.working_directory) end Aruba.configure do |config| puts %(The default value is "#{config.home_directory}") end """ Then I successfully run `cucumber` Then the output should contain: """ The default value is "/home/ """ Scenario: Set to some other path (deprecated) Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| # use current working directory config.home_directory = '/tmp/home' end Aruba.configure do |config| puts %(The default value is "#{config.home_directory}") end """ Then I successfully run `cucumber` Then the output should contain: """ The default value is "/tmp/home" """ ruby-aruba-0.14.1/features/configuration/io_timeout.feature000066400000000000000000000014061267252361200240740ustar00rootroot00000000000000Feature: Configure timeout for io of commands As a developer I want to configure the timeout waiting for io of a command In order to support some longer running commands Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts %(The default value is "#{config.io_wait_timeout}") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "0.1" """ Scenario: Modify value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| config.io_wait_timeout = 2 end """ Then I successfully run `cucumber` ruby-aruba-0.14.1/features/configuration/keep_ansi.feature000066400000000000000000000014321267252361200236540ustar00rootroot00000000000000Feature: Configure if ansi color codes should be stripped off from command output (deprecated) As a developer I want to strip off ansi color codes In order to make checking of those outputs easier Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts %(The default value is "#{config.keep_ansi}") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "false" """ Scenario: Modify value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| config.keep_ansi = true end """ Then I successfully run `cucumber` ruby-aruba-0.14.1/features/configuration/log_level.feature000066400000000000000000000016751267252361200236770ustar00rootroot00000000000000Feature: Configure Log level of aruba logger As a developer I want to configure the level of information put to output by logger In order to modify the amount of information Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts %(The default value is "#{config.log_level}") end """ When I successfully run `cucumber` Then the output should contain: """ruby The default value is "info" """ Scenario: Modify value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| config.log_level = :warn end Aruba.configure do |config| puts %(The default value is "#{config.log_level}") end """ Then I successfully run `cucumber` Then the output should contain: """ The default value is "warn" """ ruby-aruba-0.14.1/features/configuration/physical_block_size.feature000066400000000000000000000026051267252361200257410ustar00rootroot00000000000000Feature: Configure the phsical block size of disk As a developer I want to configure the physical block size In order to make the disk usage work for my application's setup Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts %(The default value is "#{config.physical_block_size}") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "512" """ Scenario: Set the block size to something else which is a power of two Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| # use current working directory config.physical_block_size = 4096 end Aruba.configure do |config| puts %(The default value is "#{config.physical_block_size}") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "4096" """ Scenario: The value needs to be a power of two, otherwise it will fail Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| config.physical_block_size = 3 end """ When I run `cucumber` Then the output should contain: """ Contract violation for argument """ ruby-aruba-0.14.1/features/configuration/remove_ansi_escape_sequences.feature000066400000000000000000000017441267252361200276260ustar00rootroot00000000000000Feature: Configure if ansi color codes should be stripped off from command output As a developer I want to strip off ansi color codes In order to make checking of those outputs easier Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ Aruba.configure do |config| puts %(The default value is "#{config.remove_ansi_escape_sequences}") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "true" """ Scenario: Modify value Given a file named "features/support/aruba.rb" with: """ Aruba.configure do |config| config.remove_ansi_escape_sequences = false end Aruba.configure do |config| puts %(The value is "#{config.remove_ansi_escape_sequences}") end """ Then I successfully run `cucumber` And the output should contain: """ The value is "false" """ ruby-aruba-0.14.1/features/configuration/root_directory.feature000066400000000000000000000012551267252361200247700ustar00rootroot00000000000000Feature: Use root directory of aruba As a developer I want to use the root directory of aruba In order to use it elsewhere Background: Given I use the fixture "cli-app" Scenario: Default configuration Given a file named "features/support/aruba.rb" with: """ Aruba.configure do |config| puts config.root_directory end """ When I successfully run `cucumber` Then the output should contain: """ tmp/aruba """ Scenario: Modify value Given a file named "features/support/aruba.rb" with: """ Aruba.configure do |config| config.root_directory = '/tmp/' end """ Then I successfully run `cucumber` ruby-aruba-0.14.1/features/configuration/startup_wait_time.feature000066400000000000000000000025161267252361200254660ustar00rootroot00000000000000Feature: Set time to wait after spawning command As a developer I want to configure a time span to wait after the command was spawned In order to prevent failure of some commands which take a little bit longer to load. If you setup a ruby script, this may load bundler. This makes the script to start up a little bit longer. If you want to run a command in background, starting the command in a background process may take longer then sending it a signal. If you experience some brittle tests with background commands, try to set the `#startup_wait_time`. Background: Given I use the fixture "cli-app" Scenario: Default value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| puts %(The default value is "#{config.startup_wait_time}") end """ When I successfully run `cucumber` Then the output should contain: """ The default value is "0" """ Scenario: Modify value Given a file named "features/support/aruba.rb" with: """ruby Aruba.configure do |config| config.startup_wait_time = 2 end Aruba.configure do |config| puts %(The new value is "#{config.startup_wait_time}") end """ Then I successfully run `cucumber` Then the output should contain: """ The new value is "2" """ ruby-aruba-0.14.1/features/configuration/usage.feature000066400000000000000000000110041267252361200230160ustar00rootroot00000000000000Feature: Usage of configuration You can configure `aruba` in two ways: 1. Using `Aruba.configure`-block 2. Using `aruba.config.