Method: RSpec::Core::Configuration#define_derived_metadata

Defined in:
lib/rspec/core/configuration.rb

#define_derived_metadata(*filters) {|metadata| ... } ⇒ void

Defines a callback that can assign derived metadata values.

Examples:

RSpec.configure do |config|
  # Tag all groups and examples in the spec/unit directory with
  # :type => :unit
  config.(:file_path => %r{/spec/unit/}) do ||
    [:type] = :unit
  end
end

Parameters:

  • filters (Array<Symbol>, Hash)

    metadata filters that determine which example or group metadata hashes the callback will be triggered for. If none are given, the callback will be run against the metadata hashes of all groups and examples.

Yield Parameters:

  • metadata (Hash)

    original metadata hash from an example or group. Mutate this in your block as needed.



1888
1889
1890
1891
# File 'lib/rspec/core/configuration.rb', line 1888

def (*filters, &block)
  meta = Metadata.build_hash_from(filters, :warn_about_example_group_filtering)
  @derived_metadata_blocks.append(block, meta)
end