Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix example name capture to use #description when available

  • Loading branch information...
commit 48fd0c7a7ff3b2475275e7fa487bf6c26e64e6a3 1 parent 8ef5ce2
Nick Sieger nicksieger authored
Showing with 27 additions and 4 deletions.
  1. +3 −2 lib/ci/reporter/rspec.rb
  2. +24 −2 spec/ci/reporter/rspec_spec.rb
5 lib/ci/reporter/rspec.rb
View
@@ -1,4 +1,4 @@
-# (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
+# (c) Copyright 2006-2008 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.
@@ -65,6 +65,7 @@ def add_example_group(example_group)
def example_started(name)
@formatter.example_started(name)
+ name = name.description if name.respond_to?(:description)
spec = TestCase.new name
@suite.testcases << spec
spec.start
@@ -131,4 +132,4 @@ def initialize(*args)
end
end
end
-end
+end
26 spec/ci/reporter/rspec_spec.rb
View
@@ -1,4 +1,4 @@
-# (c) Copyright 2006-2007 Nick Sieger <nicksieger@gmail.com>
+# (c) Copyright 2006-2008 Nick Sieger <nicksieger@gmail.com>
# See the file LICENSE.txt included with the distribution for
# software license details.
@@ -83,4 +83,26 @@
@fmt.example_passed("should pass")
@fmt.dump_summary(0.1, 1, 0, 0)
end
-end
+
+ it "should use the example #description method when available" do
+ group = mock "example group"
+ group.stub!(:description).and_return "group description"
+ example = mock "example"
+ example.stub!(:description).and_return "should do something"
+
+ @formatter.should_receive(:start)
+ @formatter.should_receive(:add_example_group).with(group)
+ @formatter.should_receive(:example_started).with(example).once
+ @formatter.should_receive(:example_passed).once
+ @formatter.should_receive(:dump_summary)
+ @report_mgr.should_receive(:write_report).and_return do |suite|
+ suite.testcases.last.name.should == "should do something"
+ end
+
+ @fmt.start(2)
+ @fmt.add_example_group(group)
+ @fmt.example_started(example)
+ @fmt.example_passed(example)
+ @fmt.dump_summary(0.1, 1, 0, 0)
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.