Sha256: cc53427b10355f236d1b2bd47214e6233c44c362a449220811826dd1ef3d6a07

Contents?: true

Size: 1.4 KB

Versions: 191

Compression:

Stored size: 1.4 KB

Contents

require 'mspec/runner/actions/filter'

# TagListAction - prints out the descriptions for any specs
# tagged with +tags+. If +tags+ is an empty list, prints out
# descriptions for any specs that are tagged.
class TagListAction
  def initialize(tags=nil)
    @tags = tags.nil? || tags.empty? ? nil : Array(tags)
    @filter = nil
  end

  # Returns true. This enables us to match any tag when loading
  # tags from the file.
  def include?(arg)
    true
  end

  # Returns true if any tagged descriptions matches +string+.
  def ===(string)
    @filter === string
  end

  # Prints a banner about matching tagged specs.
  def start
    if @tags
      print "\nListing specs tagged with #{@tags.map { |t| "'#{t}'" }.join(", ") }\n\n"
    else
      print "\nListing all tagged specs\n\n"
    end
  end

  # Creates a MatchFilter for specific tags or for all tags.
  def load
    @filter = nil
    desc = MSpec.read_tags(@tags || self).map { |t| t.description }
    @filter = MatchFilter.new(nil, *desc) unless desc.empty?
  end

  # Prints the spec description if it matches the filter.
  def after(state)
    return unless self === state.description
    print state.description, "\n"
  end

  def register
    MSpec.register :start, self
    MSpec.register :load,  self
    MSpec.register :after, self
  end

  def unregister
    MSpec.unregister :start, self
    MSpec.unregister :load,  self
    MSpec.unregister :after, self
  end
end

Version data entries

191 entries across 167 versions & 4 rubygems

Version Path
rhodes-7.6.0 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-7.5.1 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-7.4.1 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-7.1.17 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-6.2.0 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-6.0.11 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-5.5.18 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-5.5.17 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-5.5.15 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-5.5.0.22 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-5.5.2 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-5.5.0.7 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-5.5.0.3 lib/extensions/mspec/mspec/runner/actions/taglist.rb
rhodes-5.5.0 lib/extensions/mspec/mspec/runner/actions/taglist.rb
tauplatform-1.0.3 lib/extensions/mspec/mspec/runner/actions/taglist.rb
mspec-1.9.1 lib/mspec/runner/actions/taglist.rb
mspec-1.9.0 lib/mspec/runner/actions/taglist.rb
tauplatform-1.0.2 lib/extensions/mspec/mspec/runner/actions/taglist.rb
tauplatform-1.0.1 lib/extensions/mspec/mspec/runner/actions/taglist.rb
mspec-1.8.0 lib/mspec/runner/actions/taglist.rb