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

Commit b77d5bd

Browse files
committed
Add some missing keys to RESERVED_KEYS.
…and add a spec enforcing that it is always up-to-date.
1 parent ea3d536 commit b77d5bd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/rspec/core/metadata.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,8 @@ def full_description
322322
# @private
323323
RESERVED_KEYS = [
324324
:description,
325+
:description_args,
326+
:described_class,
325327
:example_group,
326328
:parent_example_group,
327329
:execution_result,
@@ -332,7 +334,8 @@ def full_description
332334
:line_number,
333335
:location,
334336
:scoped_id,
335-
:block
337+
:block,
338+
:shared_group_inclusion_backtrace
336339
]
337340
end
338341

spec/rspec/core/metadata_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ module Core
3131

3232
end
3333

34+
specify 'RESERVED_KEYS contains all keys assigned by RSpec (and vice versa)' do
35+
group = RSpec.describe("group")
36+
example = group.example("example") { }
37+
nested_group = group.describe("nested")
38+
39+
assigned_keys = group.metadata.keys | example.metadata.keys | nested_group.metadata.keys
40+
expect(RSpec::Core::Metadata::RESERVED_KEYS).to match_array(assigned_keys)
41+
end
42+
3443
context "when created" do
3544
Metadata::RESERVED_KEYS.each do |key|
3645
it "prohibits :#{key} as a hash key for an example group" do

0 commit comments

Comments
 (0)