public
Description: Behaviour Driven Development framework for Ruby
Homepage: http://rspec.info
Clone URL: git://github.com/dchelimsky/rspec.git
Click here to lend your support to: rspec and make a donation at www.pledgie.com !
don't report example groups with no examples [#412 status:resolved]
dchelimsky (author)
Sun Jun 15 09:07:32 -0700 2008
commit  4905ace22d4579b0851c2d3fe02e36bedb12571e
tree    466c931bc1800c34222d863bc6d6a5b5ce1f8403
parent  bb3a82f66124ba93a7cd97590684b893b832c59d
...
119
120
121
122
 
123
124
125
...
119
120
121
 
122
123
124
125
0
@@ -119,7 +119,7 @@ module Spec
0
 
0
       def run
0
         examples = examples_to_run
0
-        reporter.add_example_group(self)
0
+        reporter.add_example_group(self) unless examples_to_run.empty?
0
         return true if examples.empty?
0
         return dry_run(examples) if dry_run?
0
 
...
128
129
130
 
 
 
131
132
 
133
134
135
...
518
519
520
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
522
523
524
...
128
129
130
131
132
133
134
 
135
136
137
138
...
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
0
@@ -128,8 +128,11 @@ module Spec
0
             def testify
0
               raise "This is not a real test"
0
             end
0
+            def should_something
0
+              # forces the run
0
+            end
0
           end
0
-          example_group.examples.length.should == 0
0
+          example_group.examples.length.should == 1
0
           example_group.run.should be_true
0
         end
0
 
0
@@ -518,6 +521,22 @@ module Spec
0
           example_group.registration_backtrace.join("\n").should include("#{__FILE__}:#{__LINE__-1}")
0
         end
0
       end
0
+      
0
+      describe "#run" do
0
+        it "should add_example_group if there are any examples to run" do
0
+          example_group = Class.new(ExampleGroup) do
0
+            it "should do something" do end
0
+          end
0
+          reporter.should_receive(:add_example_group)
0
+          example_group.run
0
+        end
0
+
0
+        it "should NOT add_example_group if there are no examples to run" do
0
+          example_group = Class.new(ExampleGroup) do end
0
+          reporter.should_not_receive(:add_example_group)
0
+          example_group.run
0
+        end
0
+      end
0
     end
0
   end
0
 end
0
\ No newline at end of file

Comments