-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
767 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
features/api/environment/append_environment_variable.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
Feature: 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: | ||
""" | ||
require 'spec_helper' | ||
RSpec.describe 'Long running command', :type => :aruba do | ||
before(:each) { append_environment_variable 'LONG_LONG_VARIABLE', 'a' } | ||
before(:each) { run('env') } | ||
it { expect(last_command.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: | ||
""" | ||
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') } | ||
it { expect(last_command.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: | ||
""" | ||
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') } | ||
it { expect(last_command.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: | ||
""" | ||
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') } | ||
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: | ||
""" | ||
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') } | ||
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 |
118 changes: 118 additions & 0 deletions
118
features/api/environment/prepend_environment_variable.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
Feature: 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: | ||
""" | ||
require 'spec_helper' | ||
RSpec.describe 'Long running command', :type => :aruba do | ||
before(:each) { prepend_environment_variable 'LONG_LONG_VARIABLE', 'a' } | ||
before(:each) { run('env') } | ||
it { expect(last_command.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: | ||
""" | ||
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') } | ||
it { expect(last_command.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: | ||
""" | ||
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') } | ||
it { expect(last_command.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: | ||
""" | ||
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') } | ||
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: | ||
""" | ||
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') } | ||
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 |
Oops, something went wrong.