Skip to content

Commit ff62676

Browse files
committed
Remove leading space from full description when no parent description.
1 parent 01f1072 commit ff62676

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/rspec/core/metadata.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ def description_separator(parent_part, child_part)
178178

179179
def build_description_from(parent_description=nil, my_description=nil)
180180
return parent_description.to_s unless my_description
181+
return my_description.to_s if parent_description.to_s == ''
181182
separator = description_separator(parent_description, my_description)
182183
(parent_description.to_s + separator) << my_description.to_s
183184
end

spec/rspec/core/metadata_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,26 @@ def group_value_for(*args)
550550
end
551551
end
552552

553+
it "omits description from groups with a `nil` description" do
554+
value = nil
555+
556+
RSpec.describe do
557+
value = example("example").metadata[:full_description]
558+
end
559+
560+
expect(value).to eq("example")
561+
end
562+
563+
it "omits description from groups with a description of `''`" do
564+
value = nil
565+
566+
RSpec.describe "" do
567+
value = example("example").metadata[:full_description]
568+
end
569+
570+
expect(value).to eq("example")
571+
end
572+
553573
it "concats nested example group descriptions" do
554574
group_value = example_value = nil
555575

0 commit comments

Comments
 (0)