Skip to content

Commit

Permalink
Groups should not have an execution result.
Browse files Browse the repository at this point in the history
  • Loading branch information
myronmarston committed Feb 12, 2016
1 parent 59f4519 commit 3aa5aad
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
@@ -1,6 +1,11 @@
### Development
[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.5.0.beta1...master)

Enhancements:

* Remove unneeded `:execution_result` example groups metadata, saving a
bit of memory. (Myron Marston, #2172)

Bug Fixes:

* Prevent a `TypeError` from occuring when running via the rake task when
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/core/metadata.rb
Expand Up @@ -128,7 +128,6 @@ def initialize(metadata, user_metadata, index_provider, description_args, block)
def populate
ensure_valid_user_keys

metadata[:execution_result] = Example::ExecutionResult.new
metadata[:block] = block
metadata[:description_args] = description_args
metadata[:description] = build_description_from(*metadata[:description_args])
Expand Down Expand Up @@ -219,6 +218,7 @@ def self.create(group_metadata, user_metadata, index_provider, description, bloc
end)
group_metadata.update(example_metadata)

example_metadata[:execution_result] = Example::ExecutionResult.new
example_metadata[:example_group] = group_metadata
example_metadata[:shared_group_inclusion_backtrace] = SharedExampleGroupInclusionStackFrame.current_backtrace
example_metadata.delete(:parent_example_group)
Expand Down
27 changes: 24 additions & 3 deletions spec/rspec/core/metadata_spec.rb
Expand Up @@ -141,15 +141,36 @@ def metadata_for(*args)
end

it 'does not include example-group specific keys' do
meta = nil
example_meta = nil
group_meta = nil

RSpec.describe "group" do
context "nested" do
meta = example("foo").metadata
group_meta = metadata
example_meta = example("foo").metadata
end
end

expect(meta.keys).not_to include(:parent_example_group)
expect(group_meta.keys - example_meta.keys).to contain_exactly(:parent_example_group)
end
end

context "for an example group" do
it 'does not include example specific keys' do
example_meta = nil
group_meta = nil

RSpec.describe "group" do
context "nested" do
group_meta = metadata
example_meta = example("foo").metadata
end
end

expect(example_meta.keys - group_meta.keys).to contain_exactly(
:execution_result, :last_run_status, :skip,
:shared_group_inclusion_backtrace, :example_group
)
end
end

Expand Down

0 comments on commit 3aa5aad

Please sign in to comment.