Permalink
Browse files

Fix bug where full descriptions of groups nested 3 deep were repeated.

- Fixes #477.
  • Loading branch information...
dchelimsky committed Oct 30, 2011
1 parent f87e9d7 commit 7712c5b7c0cedac89dd974d35605fcad59dd812c
Showing with 23 additions and 7 deletions.
  1. +1 −0 Changelog.md
  2. +1 −1 lib/rspec/core/metadata.rb
  3. +21 −6 spec/rspec/core/metadata_spec.rb
View
@@ -9,6 +9,7 @@
* Bug fixes
* Make sure the `bar` in `--tag foo:bar` makes it to DRb (Aaron Gibralter)
+ * Fix bug where full descriptions of groups nested 3 deep were repeated.
* Deprecations
* :alias option on `configuration.add_setting`. Use `:alias_with` on the
@@ -76,7 +76,7 @@ def described_class_for(*)
def full_description_for(*)
build_description_from(*ancestors.reverse.map do |a|
- a.has_key?(:full_description) ? a[:full_description] : a[:description_args]
+ a[:description_args]
end.flatten)
end
@@ -22,7 +22,6 @@ module Core
end
describe "#filter_applies?" do
-
let(:parent_group_metadata) { Metadata.new.process('parent group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
let(:group_metadata) { Metadata.new(parent_group_metadata).process('group', :caller => ["foo_spec.rb:#{__LINE__}"]) }
let(:example_metadata) { group_metadata.for_example('example', :caller => ["foo_spec.rb:#{__LINE__}"], :if => true) }
@@ -313,13 +312,29 @@ module Core
child.for_example('example', child)[:full_description].should eq("parent child example")
end
+ it "concats nested example group descriptions three deep" do
+ grandparent = Metadata.new
+ grandparent.process('grandparent')
+
+ parent = Metadata.new(grandparent)
+ parent.process('parent')
+
+ child = Metadata.new(parent)
+ child.process('child')
+
+ grandparent[:example_group][:full_description].should eq("grandparent")
+ parent[:example_group][:full_description].should eq("grandparent parent")
+ child[:example_group][:full_description].should eq("grandparent parent child")
+ child.for_example('example', child)[:full_description].should eq("grandparent parent child example")
+ end
+
%w[# . ::].each do |char|
context "with a 2nd arg starting with #{char}" do
- it "removes the space" do
- m = Metadata.new
- m.process(Array, "#{char}method")
- m[:example_group][:full_description].should eq("Array#{char}method")
- end
+ it "removes the space" do
+ m = Metadata.new
+ m.process(Array, "#{char}method")
+ m[:example_group][:full_description].should eq("Array#{char}method")
+ end
end
end

0 comments on commit 7712c5b

Please sign in to comment.