module RSpec::Core::MetadataHashBuilder::Common

@private

Public Instance Methods

build_metadata_hash_from(args) click to toggle source
# File lib/rspec/core/metadata_hash_builder.rb, line 7
def build_metadata_hash_from(args)
  metadata = args.last.is_a?(Hash) ? args.pop : {}

  if RSpec.configuration.treat_symbols_as_metadata_keys_with_true_values?
    add_symbols_to_hash(metadata, args)
  else
    warn_about_symbol_usage(args)
  end

  metadata
end

Private Instance Methods

add_symbols_to_hash(hash, args) click to toggle source
# File lib/rspec/core/metadata_hash_builder.rb, line 21
def add_symbols_to_hash(hash, args)
  while args.last.is_a?(Symbol)
    hash[args.pop] = true
  end
end
warn_about_symbol_usage(args) click to toggle source
# File lib/rspec/core/metadata_hash_builder.rb, line 27
def warn_about_symbol_usage(args)
  symbols = args.select { |a| a.is_a?(Symbol) }
  return if symbols.empty?
  Kernel.warn symbol_metadata_warning(symbols)
end