class RSpec::Core::Example

def duplicate_with(metadata_overrides={})

Returns:
  • (Example) - a duplicate of the example with modified metadata

Parameters:
  • metadata_overrides (Hash) -- the hash to override the example metadata
def duplicate_with(metadata_overrides={})
  new_metadata = metadata.clone.merge(metadata_overrides)
  RSpec::Core::Metadata::RESERVED_KEYS.each do |reserved_key|
    new_metadata.delete reserved_key
  end
  # don't clone the example group because the new example
  # must belong to the same example group (not a clone).
  #
  # block is nil in new_metadata so we have to get it from metadata.
  Example.new(example_group, description.clone,
              new_metadata, metadata[:block])
end