Permalink
Browse files

Fix failure messages not containing the full description.

  • Loading branch information...
1 parent 4bc5bf2 commit 11f1374a6698a50efbfd636732fab5cdde5deff1 @arthurschreiber committed Sep 18, 2012
Showing with 35 additions and 1 deletion.
  1. +12 −1 lib/spec/example_group.tcl
  2. +23 −0 spec/example_group_spec.tcl
@@ -97,7 +97,18 @@ namespace eval Spec {
}
:public method full_description {} {
- set :description
+ set full_description ""
+
+ foreach ancestor [lreverse [:ancestors]] {
+ set description [$ancestor description]
+ if { $full_description == "" || [regexp {^(#|::|\.)} $description] } {
+ append full_description "$description"
+ } else {
+ append full_description " $description"
+ }
+ }
+
+ return $full_description
}
:public method before { what block } {
@@ -227,6 +227,29 @@ describe "ancestors" {
}
}
+describe "full_description" {
+ it "returns the complete description string" {
+ set group [::Spec::ExampleGroup describe "SomeClass" {
+ describe "#some_method" { }
+
+ describe ".some_class_method" { }
+
+ describe "::NestedClass" {
+ describe "::DeeplyNestedClass" {}
+ }
+
+ describe "does something" { }
+ }]
+
+ expect [$group full_description] to equal "SomeClass"
+ expect [[lindex [$group children] 0] full_description] to equal "SomeClass#some_method"
+ expect [[lindex [$group children] 1] full_description] to equal "SomeClass.some_class_method"
+ expect [[lindex [$group children] 2] full_description] to equal "SomeClass::NestedClass"
+ expect [[lindex [[lindex [$group children] 2] children] 0] full_description] to equal "SomeClass::NestedClass::DeeplyNestedClass"
+ expect [[lindex [$group children] 3] full_description] to equal "SomeClass does something"
+ }
+}
+
describe "running the examples" {
it "returns true if all examples pass" {
set group [::Spec::ExampleGroup describe "group" {

0 comments on commit 11f1374

Please sign in to comment.