Skip to content

Commit

Permalink
Merge pull request #309 from dg-ratiodata/feature/move_to_event_queue
Browse files Browse the repository at this point in the history
Make use of commands easier by introducing an event queue
  • Loading branch information
Dennis Günnewig committed Nov 26, 2015
2 parents bf918ac + 3c46eec commit 018b486
Show file tree
Hide file tree
Showing 92 changed files with 2,302 additions and 834 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ group :development, :test do
gem 'simplecov', '~> 0.10'

# Test api
gem 'rspec', '~> 3.3.0'
gem 'rspec', '~> 3.4'
gem 'fuubar', '~> 2.0.0'

# using platform for this make bundler complain about the same gem given
Expand Down
22 changes: 21 additions & 1 deletion History.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
* 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.

# Old releases

## [v0.10.2](https://github.com/cucumber/aruba/compare/v0.10.1...v0.10.2)

* Fixed problem in regex after merge of step definitions

# Old releases

## [v0.10.1](https://github.com/cucumber/aruba/compare/v0.10.0...v0.10.1)

Expand Down Expand Up @@ -445,6 +447,24 @@

# Upcoming un-released versions

## [v0.11.0.pre2](https://github.com/cucumber/aruba/compare/v0.11.pre2...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

## [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
Expand Down
1 change: 1 addition & 0 deletions aruba.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'rspec-expectations', '>= 2.99'
s.add_runtime_dependency 'contracts', '~> 0.9'
s.add_runtime_dependency 'thor', '~> 0.19'
s.add_runtime_dependency 'event-bus', '~> 0.2.0'

s.add_development_dependency 'bundler', '~> 1.10.2'

Expand Down
83 changes: 83 additions & 0 deletions features/api/command/find_command.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
Feature: Find a started command

This feature is experimental and may change without further notice.

Background:
Given I use a fixture named "cli-app"

Scenario: Exising 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-Exising 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
50 changes: 50 additions & 0 deletions features/api/command/last_command_started.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Feature: 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
89 changes: 89 additions & 0 deletions features/api/command/last_command_stopped.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
Feature: 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
Loading

0 comments on commit 018b486

Please sign in to comment.