Class: TagListAction
Overview
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.
Direct Known Subclasses
Instance Method Summary collapse
-
#===(string) ⇒ Object
Returns true if any tagged descriptions matches
string
. -
#after(state) ⇒ Object
Prints the spec description if it matches the filter.
-
#include?(arg) ⇒ Boolean
Returns true.
-
#initialize(tags = nil) ⇒ TagListAction
constructor
A new instance of TagListAction.
-
#load ⇒ Object
Creates a MatchFilter for specific tags or for all tags.
- #register ⇒ Object
-
#start ⇒ Object
Prints a banner about matching tagged specs.
- #unregister ⇒ Object
Constructor Details
#initialize(tags = nil) ⇒ TagListAction
Returns a new instance of TagListAction.
7 8 9 10 |
# File 'lib/mspec/runner/actions/taglist.rb', line 7 def initialize(=nil) @tags = .nil? || .empty? ? nil : Array() @filter = nil end |
Instance Method Details
#===(string) ⇒ Object
Returns true if any tagged descriptions matches string
.
19 20 21 |
# File 'lib/mspec/runner/actions/taglist.rb', line 19 def ===(string) @filter === string end |
#after(state) ⇒ Object
Prints the spec description if it matches the filter.
40 41 42 43 |
# File 'lib/mspec/runner/actions/taglist.rb', line 40 def after(state) return unless self === state.description print state.description, "\n" end |
#include?(arg) ⇒ Boolean
Returns true. This enables us to match any tag when loading tags from the file.
14 15 16 |
# File 'lib/mspec/runner/actions/taglist.rb', line 14 def include?(arg) true end |
#load ⇒ Object
Creates a MatchFilter for specific tags or for all tags.
33 34 35 36 37 |
# File 'lib/mspec/runner/actions/taglist.rb', line 33 def load @filter = nil desc = MSpec.(@tags || self).map { |t| t.description } @filter = MatchFilter.new(nil, *desc) unless desc.empty? end |
#register ⇒ Object
45 46 47 48 49 |
# File 'lib/mspec/runner/actions/taglist.rb', line 45 def register MSpec.register :start, self MSpec.register :load, self MSpec.register :after, self end |
#start ⇒ Object
Prints a banner about matching tagged specs.
24 25 26 27 28 29 30 |
# File 'lib/mspec/runner/actions/taglist.rb', line 24 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 |
#unregister ⇒ Object
51 52 53 54 55 |
# File 'lib/mspec/runner/actions/taglist.rb', line 51 def unregister MSpec.unregister :start, self MSpec.unregister :load, self MSpec.unregister :after, self end |