Permalink
Browse files

Fixed a bug where failures in nested groups were always detected as s…

…uccess.
  • Loading branch information...
1 parent 7910d7f commit f8a28d7cad1ab697eada0f80169cc6b748b4c790 @aslakhellesoy aslakhellesoy committed with dchelimsky Jun 16, 2010
Showing with 53 additions and 1 deletion.
  1. +52 −0 features/command_line/exit_status.feature
  2. +1 −1 lib/rspec/core/example_group.rb
@@ -0,0 +1,52 @@
+Feature: exit status
+ In order to fail the build when it should,
+ the spec CLI should exit with an appropriate
+ exit status
+
+ Background:
+ Given a file named "ok_spec.rb" with:
+ """
+ describe "ok" do
+ it "passes" do
+ end
+ end
+ """
+ Given a file named "ko_spec.rb" with:
+ """
+ describe "KO" do
+ it "fails" do
+ raise "KO"
+ end
+ end
+ """
+ Given a file named "nested_ko_spec.rb" with:
+ """
+ describe "KO" do
+ describe "nested" do
+ it "fails" do
+ raise "KO"
+ end
+ end
+ end
+ """
+
+ Scenario: exit with 0 when all pass
+ When I run "ruby -rubygems ../../bin/rspec ok_spec.rb"
+ Then it should pass with:
+ """
+ 1 example, 0 failures
+ """
+
+ Scenario: exit with 1 when one fails
+ When I run "ruby -rubygems ../../bin/rspec ko_spec.rb"
+ Then it should fail with:
+ """
+ 1 example, 1 failure
+ """
+
+ Scenario: exit with 1 when one fails in a nested one
+ When I run "ruby -rubygems ../../bin/rspec nested_ko_spec.rb"
+ Then it should fail with:
+ """
+ 1 example, 1 failure
+ """
@@ -174,7 +174,7 @@ def self.run(reporter)
eval_before_alls(example_group_instance)
result_for_this_group = run_examples(example_group_instance, reporter)
results_for_descendants = children.map {|child| child.run(reporter)}
- result_for_this_group && (children.empty? ? true : results_for_descendants)
+ result_for_this_group && (children.empty? ? true : results_for_descendants.all?)
ensure
eval_after_alls(example_group_instance)
end

0 comments on commit f8a28d7

Please sign in to comment.