[DRE-commits] [ruby-aruba] 74/98: Add configuration option to enable activation of announcer channels when a command fails
Hideki Yamane
henrich at moszumanska.debian.org
Tue Mar 22 12:20:42 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 4e7dafd8220a62ff07d706208c6642a20e944c15
Author: Reto Kaiser <reto at cargomedia.ch>
Date: Mon Jan 25 10:31:13 2016 +0100
Add configuration option to enable activation of announcer channels when a command fails
---
features/api/command/run_simple.feature | 39 ++++++++++++++++++++--
.../activate_announcer_on_command_failure.feature | 38 +++++++++++++++++++++
lib/aruba/api/command.rb | 9 +++--
lib/aruba/config.rb | 6 ++--
4 files changed, 86 insertions(+), 6 deletions(-)
diff --git a/features/api/command/run_simple.feature b/features/api/command/run_simple.feature
index 795cf78..1057f89 100644
--- a/features/api/command/run_simple.feature
+++ b/features/api/command/run_simple.feature
@@ -8,7 +8,7 @@ Feature: Run command
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"
@@ -107,7 +107,7 @@ Feature: Run command
Given an executable named "bin/cli" with:
"""bash
#!/usr/bin/env bash
-
+
function initialize_script {
sleep 2
}
@@ -205,3 +205,38 @@ Feature: Run command
"""
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
+ """
diff --git a/features/configuration/activate_announcer_on_command_failure.feature b/features/configuration/activate_announcer_on_command_failure.feature
new file mode 100644
index 0000000..0bd344c
--- /dev/null
+++ b/features/configuration/activate_announcer_on_command_failure.feature
@@ -0,0 +1,38 @@
+Feature: 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]"
+ """
diff --git a/lib/aruba/api/command.rb b/lib/aruba/api/command.rb
index 2db08e5..adeceb0 100644
--- a/lib/aruba/api/command.rb
+++ b/lib/aruba/api/command.rb
@@ -277,8 +277,13 @@ module Aruba
end
if fail_on_error
- expect(command).to have_finished_in_time
- expect(command).to be_successfully_executed
+ begin
+ expect(command).to have_finished_in_time
+ expect(command).to be_successfully_executed
+ rescue RSpec::Expectations::ExpectationNotMetError => e
+ aruba.announcer.activate(aruba.config.activate_announcer_on_command_failure)
+ raise e
+ end
end
end
# rubocop:enable Metrics/CyclomaticComplexity
diff --git a/lib/aruba/config.rb b/lib/aruba/config.rb
index 493fc07..487a3c4 100644
--- a/lib/aruba/config.rb
+++ b/lib/aruba/config.rb
@@ -26,9 +26,9 @@ module Aruba
option_accessor :working_directory, :contract => { Aruba::Contracts::RelativePath => Aruba::Contracts::RelativePath }, :default => 'tmp/aruba'
if RUBY_VERSION < '1.9'
- option_reader :fixtures_path_prefix, :contract => { None => String }, :default => '%'
+ option_reader :fixtures_path_prefix, :contract => { None => String }, :default => '%'
else
- option_reader :fixtures_path_prefix, :contract => { None => String }, :default => ?%
+ option_reader :fixtures_path_prefix, :contract => { None => String }, :default => ?%
end
option_accessor :exit_timeout, :contract => { Num => Num }, :default => 15
@@ -64,6 +64,8 @@ module Aruba
option_accessor :physical_block_size, :contract => { Aruba::Contracts::IsPowerOfTwo => Aruba::Contracts::IsPowerOfTwo }, :default => 512
option_accessor :console_history_file, :contract => { String => String }, :default => '~/.aruba_history'
+
+ option_accessor :activate_announcer_on_command_failure, :contract => { ArrayOf[Symbol] => ArrayOf[Symbol] }, :default => []
end
end
--
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