[DRE-commits] [ruby-aruba] 86/98: Added some more methods
Hideki Yamane
henrich at moszumanska.debian.org
Tue Mar 22 12:20:43 UTC 2016
This is an automated email from the git hooks/post-receive script.
henrich pushed a commit to branch debian/sid
in repository ruby-aruba.
commit 7026d600a17ea0cbd447e43452ddc0d0448963ed
Author: Max Meyer <dev at fedux.org>
Date: Sun Feb 28 20:13:00 2016 +0100
Added some more methods
---
TODO.md | 5 +++
features/steps/command/run.feature | 16 +++++++
.../append_environment_variable.feature | 52 ++++++++++++++++++++++
.../prepend_environment_variable.feature | 52 ++++++++++++++++++++++
.../environment/set_environment_variable.feature | 23 ++++++++--
lib/aruba/cucumber/command.rb | 5 +++
lib/aruba/cucumber/environment.rb | 8 ++++
7 files changed, 157 insertions(+), 4 deletions(-)
diff --git a/TODO.md b/TODO.md
index 15f6afa..5b3d565 100644
--- a/TODO.md
+++ b/TODO.md
@@ -6,3 +6,8 @@
* 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
+
diff --git a/features/steps/command/run.feature b/features/steps/command/run.feature
index 786d8cb..debd0db 100644
--- a/features/steps/command/run.feature
+++ b/features/steps/command/run.feature
@@ -48,3 +48,19 @@ Feature: Run commands
STDOUT
"""
+
+ Scenario: Run command found in "bin"-directory which is found in the current directory
+ Given a file named "features/run.feature" with:
+ """
+ Feature: Run it
+ Scenario: Run command
+ Given an executable named "bin/local_cli" with:
+ \"\"\"
+ #!/bin/bash
+ exit 0
+ \"\"\"
+ And I look for executables in "bin" within the current directory
+ When I successfully run `local_cli`
+ """
+ When I run `cucumber`
+ Then the features should all pass
diff --git a/features/steps/environment/append_environment_variable.feature b/features/steps/environment/append_environment_variable.feature
new file mode 100644
index 0000000..d9f59fe
--- /dev/null
+++ b/features/steps/environment/append_environment_variable.feature
@@ -0,0 +1,52 @@
+Feature: Append environment variable via "cucumber"-step
+
+ It is quite handy to modify the environment of a process. To make this
+ possible, `aruba` provides several steps. One of these is
+ `I append the values to environment variables:`-step. Using this step appends
+ the values. Each variable name and each value is converted to a string.
+ Otherwise `ruby` would complain about an invalid argument.
+
+ Background:
+ Given I use the fixture "cli-app"
+ And an executable named "bin/cli" with:
+ """
+ #!/bin/bash
+
+ echo $LONG_LONG_VARIABLE
+ """
+ And a file named "features/support/variables.rb" with:
+ """
+ ENV['LONG_LONG_VARIABLE'] = '1'
+ """
+
+ Scenario: Append environment variable by using a step given in table
+ Given a file named "features/home_variable.feature" with:
+ """
+ Feature: Environment Variable
+ Scenario: Run command
+ Given I append the values to the environment variables:
+ | variable | value |
+ | LONG_LONG_VARIABLE | long_value |
+ When I run `cli`
+ Then the output should contain:
+ \"\"\"
+ 1long_value
+ \"\"\"
+ """
+ When I run `cucumber`
+ Then the features should all pass
+
+ Scenario: Append single environment variable by using a step
+ Given a file named "features/home_variable.feature" with:
+ """
+ Feature: Environment Variable
+ Scenario: Run command
+ Given I append "long_value" to the environment variable "LONG_LONG_VARIABLE"
+ When I run `cli`
+ Then the output should contain:
+ \"\"\"
+ 1long_value
+ \"\"\"
+ """
+ When I run `cucumber`
+ Then the features should all pass
diff --git a/features/steps/environment/prepend_environment_variable.feature b/features/steps/environment/prepend_environment_variable.feature
new file mode 100644
index 0000000..d7b73c8
--- /dev/null
+++ b/features/steps/environment/prepend_environment_variable.feature
@@ -0,0 +1,52 @@
+Feature: Prepend environment variable via "cucumber"-step
+
+ It is quite handy to modify the environment of a process. To make this
+ possible, `aruba` provides several steps. One of these is
+ `I prepend the values to environment variables:`-step. Using this step prepends
+ the values. Each variable name and each value is converted to a string.
+ Otherwise `ruby` would complain about an invalid argument.
+
+ Background:
+ Given I use the fixture "cli-app"
+ And an executable named "bin/cli" with:
+ """
+ #!/bin/bash
+
+ echo $LONG_LONG_VARIABLE
+ """
+ And a file named "features/support/variables.rb" with:
+ """
+ ENV['LONG_LONG_VARIABLE'] = '1'
+ """
+
+ Scenario: Prepend environment variable by using a step given in table
+ Given a file named "features/home_variable.feature" with:
+ """
+ Feature: Environment Variable
+ Scenario: Run command
+ Given I prepend the values to the environment variables:
+ | variable | value |
+ | LONG_LONG_VARIABLE | long_value |
+ When I run `cli`
+ Then the output should contain:
+ \"\"\"
+ long_value1
+ \"\"\"
+ """
+ When I run `cucumber`
+ Then the features should all pass
+
+ Scenario: Prepend single environment variable by using a step
+ Given a file named "features/home_variable.feature" with:
+ """
+ Feature: Environment Variable
+ Scenario: Run command
+ Given I prepend "long_value" to the environment variable "LONG_LONG_VARIABLE"
+ When I run `cli`
+ Then the output should contain:
+ \"\"\"
+ long_value1
+ \"\"\"
+ """
+ When I run `cucumber`
+ Then the features should all pass
diff --git a/features/steps/environment/set_environment_variable.feature b/features/steps/environment/set_environment_variable.feature
index 198042d..c04c1c5 100644
--- a/features/steps/environment/set_environment_variable.feature
+++ b/features/steps/environment/set_environment_variable.feature
@@ -9,15 +9,15 @@ Feature: Set environment variable via "cucumber"-step
Background:
Given I use the fixture "cli-app"
-
- Scenario: Set environment variable by using a step
- Given an executable named "bin/cli" with:
+ And an executable named "bin/cli" with:
"""
#!/bin/bash
echo $LONG_LONG_VARIABLE
"""
- And a file named "features/home_variable.feature" with:
+
+ Scenario: Set environment variable by using a step given in table
+ Given a file named "features/home_variable.feature" with:
"""
Feature: Environment Variable
Scenario: Run command
@@ -32,3 +32,18 @@ Feature: Set environment variable via "cucumber"-step
"""
When I run `cucumber`
Then the features should all pass
+
+ Scenario: Set single environment variable by using a step
+ Given a file named "features/home_variable.feature" with:
+ """
+ Feature: Environment Variable
+ Scenario: Run command
+ Given I set the environment variable "LONG_LONG_VARIABLE" to "long_value"
+ When I run `cli`
+ Then the output should contain:
+ \"\"\"
+ long_value
+ \"\"\"
+ """
+ When I run `cucumber`
+ Then the features should all pass
diff --git a/lib/aruba/cucumber/command.rb b/lib/aruba/cucumber/command.rb
index 7e07a18..53a9fca 100644
--- a/lib/aruba/cucumber/command.rb
+++ b/lib/aruba/cucumber/command.rb
@@ -416,3 +416,8 @@ When(/^I send the signal "([^"]*)" to the command (?:"([^"]*)"|(?:started last))
last_command_started.send_signal signal
end
end
+
+Given(/^I look for executables in "(.*)" within the current directory$/) do |directory|
+ prepend_environment_variable 'PATH', expand_path(directory) + ':'
+end
+
diff --git a/lib/aruba/cucumber/environment.rb b/lib/aruba/cucumber/environment.rb
index 39b1558..59448b6 100644
--- a/lib/aruba/cucumber/environment.rb
+++ b/lib/aruba/cucumber/environment.rb
@@ -6,6 +6,14 @@ Given(/^I set the environment variable "(.*)" to "(.*)"/) do |variable, value|
set_environment_variable(variable.to_s, value.to_s)
end
+Given(/^I append "(.*)" to the environment variable "(.*)"/) do |value, variable|
+ append_environment_variable(variable.to_s, value.to_s)
+end
+
+Given(/^I prepend "(.*)" to the environment variable "(.*)"/) do |value, variable|
+ prepend_environment_variable(variable.to_s, value.to_s)
+end
+
Given(/^I set the environment variables? to:/) do |table|
table.hashes.each do |row|
variable = row['variable'].to_s
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-aruba.git
More information about the Pkg-ruby-extras-commits
mailing list