Sha256: 1ea9acb1ba242e2697ef420737c29c37a5b09e8da70f30bd27bd5217c238fb31

Contents?: true

Size: 968 Bytes

Versions: 185

Compression:

Stored size: 968 Bytes

Contents

require 'mspec/runner/filters/match'

# ActionFilter is a base class for actions that are triggered by
# specs that match the filter. The filter may be specified by
# strings that match spec descriptions or by tags for strings
# that match spec descriptions.
#
# Unlike TagFilter and RegexpFilter, ActionFilter instances do
# not affect the specs that are run. The filter is only used to
# trigger the action.

class ActionFilter
  def initialize(tags=nil, descs=nil)
    @tags = Array(tags)
    descs = Array(descs)
    @sfilter = MatchFilter.new(nil, *descs) unless descs.empty?
  end

  def ===(string)
    @sfilter === string or @tfilter === string
  end

  def load
    @tfilter = nil
    return if @tags.empty?

    desc = MSpec.read_tags(@tags).map { |t| t.description }
    return if desc.empty?

    @tfilter = MatchFilter.new(nil, *desc)
  end

  def register
    MSpec.register :load, self
  end

  def unregister
    MSpec.unregister :load, self
  end
end

Version data entries

185 entries across 161 versions & 4 rubygems

Version Path
rhodes-5.5.18 lib/extensions/mspec/mspec/runner/actions/filter.rb
rhodes-5.5.17 lib/extensions/mspec/mspec/runner/actions/filter.rb
rhodes-5.5.15 lib/extensions/mspec/mspec/runner/actions/filter.rb
rhodes-5.5.0.22 lib/extensions/mspec/mspec/runner/actions/filter.rb
rhodes-5.5.2 lib/extensions/mspec/mspec/runner/actions/filter.rb
rhodes-5.5.0.7 lib/extensions/mspec/mspec/runner/actions/filter.rb
rhodes-5.5.0.3 lib/extensions/mspec/mspec/runner/actions/filter.rb
rhodes-5.5.0 lib/extensions/mspec/mspec/runner/actions/filter.rb
tauplatform-1.0.3 lib/extensions/mspec/mspec/runner/actions/filter.rb
mspec-1.9.1 lib/mspec/runner/actions/filter.rb
mspec-1.9.0 lib/mspec/runner/actions/filter.rb
tauplatform-1.0.2 lib/extensions/mspec/mspec/runner/actions/filter.rb
tauplatform-1.0.1 lib/extensions/mspec/mspec/runner/actions/filter.rb
mspec-1.8.0 lib/mspec/runner/actions/filter.rb
mspec-1.7.0 lib/mspec/runner/actions/filter.rb
mspec-1.6.0 lib/mspec/runner/actions/filter.rb
mspec-1.5.21 lib/mspec/runner/actions/filter.rb
mspec-1.5.20 lib/mspec/runner/actions/filter.rb
mspec-1.5.19 lib/mspec/runner/actions/filter.rb
mspec-1.5.18 lib/mspec/runner/actions/filter.rb