Class/Module Index [+]

Quicksearch

RSpec::Core::MetadataFilter

Contains metadata filtering logic. This has been extracted from the metadata classes because it operates ON a metadata hash but does not manage any of the state in the hash. We’re moving towards having metadata be a raw hash (not a custom subclass), so externalizing this filtering logic helps us move in that direction.

Public Instance Methods

all_apply?(filters, metadata) click to toggle source

@private

# File lib/rspec/core/metadata_filter.rb, line 17
def all_apply?(filters, metadata)
  filters.all? { |k, v| filter_applies?(k, v, metadata) }
end
any_apply?(filters, metadata) click to toggle source

@private

# File lib/rspec/core/metadata_filter.rb, line 12
def any_apply?(filters, metadata)
  filters.any? { |k, v| filter_applies?(k, v, metadata) }
end
filter_applies?(key, value, metadata) click to toggle source

@private

# File lib/rspec/core/metadata_filter.rb, line 22
def filter_applies?(key, value, metadata)
  silence_metadata_example_group_deprecations do
    return filter_applies_to_any_value?(key, value, metadata) if Array === metadata[key] && !(Proc === value)
    return location_filter_applies?(value, metadata)          if key == :locations
    return filters_apply?(key, value, metadata)               if Hash === value

    return false unless metadata.has_key?(key)

    case value
    when Regexp
      metadata[key] =~ value
    when Proc
      case value.arity
      when 0 then value.call
      when 2 then value.call(metadata[key], metadata)
      else value.call(metadata[key])
      end
    else
      metadata[key].to_s == value.to_s
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.