Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 3aa5aad

Browse files
committed
Groups should not have an execution result.
1 parent 59f4519 commit 3aa5aad

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

Changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
### Development
22
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.0.beta1...master)
33

4+
Enhancements:
5+
6+
* Remove unneeded `:execution_result` example groups metadata, saving a
7+
bit of memory. (Myron Marston, #2172)
8+
49
Bug Fixes:
510

611
* Prevent a `TypeError` from occuring when running via the rake task when

lib/rspec/core/metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ def initialize(metadata, user_metadata, index_provider, description_args, block)
128128
def populate
129129
ensure_valid_user_keys
130130

131-
metadata[:execution_result] = Example::ExecutionResult.new
132131
metadata[:block] = block
133132
metadata[:description_args] = description_args
134133
metadata[:description] = build_description_from(*metadata[:description_args])
@@ -219,6 +218,7 @@ def self.create(group_metadata, user_metadata, index_provider, description, bloc
219218
end)
220219
group_metadata.update(example_metadata)
221220

221+
example_metadata[:execution_result] = Example::ExecutionResult.new
222222
example_metadata[:example_group] = group_metadata
223223
example_metadata[:shared_group_inclusion_backtrace] = SharedExampleGroupInclusionStackFrame.current_backtrace
224224
example_metadata.delete(:parent_example_group)

spec/rspec/core/metadata_spec.rb

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,15 +141,36 @@ def metadata_for(*args)
141141
end
142142

143143
it 'does not include example-group specific keys' do
144-
meta = nil
144+
example_meta = nil
145+
group_meta = nil
145146

146147
RSpec.describe "group" do
147148
context "nested" do
148-
meta = example("foo").metadata
149+
group_meta = metadata
150+
example_meta = example("foo").metadata
149151
end
150152
end
151153

152-
expect(meta.keys).not_to include(:parent_example_group)
154+
expect(group_meta.keys - example_meta.keys).to contain_exactly(:parent_example_group)
155+
end
156+
end
157+
158+
context "for an example group" do
159+
it 'does not include example specific keys' do
160+
example_meta = nil
161+
group_meta = nil
162+
163+
RSpec.describe "group" do
164+
context "nested" do
165+
group_meta = metadata
166+
example_meta = example("foo").metadata
167+
end
168+
end
169+
170+
expect(example_meta.keys - group_meta.keys).to contain_exactly(
171+
:execution_result, :last_run_status, :skip,
172+
:shared_group_inclusion_backtrace, :example_group
173+
)
153174
end
154175
end
155176

0 commit comments

Comments
 (0)