Skip to content

Commit

Permalink
Add some missing keys to RESERVED_KEYS.
Browse files Browse the repository at this point in the history
…and add a spec enforcing that it is always up-to-date.
  • Loading branch information
myronmarston committed Feb 23, 2015
1 parent ea3d536 commit b77d5bd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rspec/core/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ def full_description
# @private
RESERVED_KEYS = [
:description,
:description_args,
:described_class,
:example_group,
:parent_example_group,
:execution_result,
Expand All @@ -332,7 +334,8 @@ def full_description
:line_number,
:location,
:scoped_id,
:block
:block,
:shared_group_inclusion_backtrace
]
end

Expand Down
9 changes: 9 additions & 0 deletions spec/rspec/core/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ module Core

end

specify 'RESERVED_KEYS contains all keys assigned by RSpec (and vice versa)' do
group = RSpec.describe("group")
example = group.example("example") { }
nested_group = group.describe("nested")

assigned_keys = group.metadata.keys | example.metadata.keys | nested_group.metadata.keys
expect(RSpec::Core::Metadata::RESERVED_KEYS).to match_array(assigned_keys)
end

context "when created" do
Metadata::RESERVED_KEYS.each do |key|
it "prohibits :#{key} as a hash key for an example group" do
Expand Down

0 comments on commit b77d5bd

Please sign in to comment.