Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve rake task report on failure #400

Merged
merged 7 commits into from
Mar 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions features/raketask.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Feature: Raketask
In order to use cucumber's rake task
As a Cuker
I do not want to see rake's backtraces when it fails
Also I want to get zero exit status code on failures
And non-zero exit status code when is pases

Background:
Given a file named "features/passing_and_failing.feature" with:
"""
Feature: Sample

Scenario: Passing
Given passing

Scenario: Failing
Given failing
"""
Given a file named "features/step_definitions/steps.rb" with:
"""
Given(/^passing$/) do
end

Given /^failing$/ do
raise "FAIL"
end
"""
Given a file named "Rakefile" with:
"""
require 'cucumber/rake/task'

SAMPLE_FEATURE_FILE = 'features/passing_and_failing.feature'

Cucumber::Rake::Task.new(:pass) do |t|
t.cucumber_opts = "#{SAMPLE_FEATURE_FILE}:3"
end

Cucumber::Rake::Task.new(:fail) do |t|
t.cucumber_opts = "#{SAMPLE_FEATURE_FILE}:6"
end
"""

Scenario: Passing feature
When I run `bundle exec rake pass`
Then the exit status should be 0

Scenario: Failing feature
When I run `bundle exec rake fail`
Then the exit status should not be 0
And the output should not contain "rake aborted!"
6 changes: 5 additions & 1 deletion lib/cucumber/rake/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ def cmd
end

def run
sh(cmd.join(" "))
sh cmd.join(" ") do |ok, res|
if !ok
exit res.exitstatus
end
end
end
end

Expand Down