Class: ActionFilter
- Defined in:
- lib/extensions/mspec/mspec/runner/actions/filter.rb
Overview
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.
Direct Known Subclasses
Instance Method Summary collapse
- #===(string) ⇒ Object
-
#initialize(tags = nil, descs = nil) ⇒ ActionFilter
constructor
A new instance of ActionFilter.
- #load ⇒ Object
- #register ⇒ Object
- #unregister ⇒ Object
Constructor Details
#initialize(tags = nil, descs = nil) ⇒ ActionFilter
Returns a new instance of ActionFilter.
13 14 15 16 17 18 |
# File 'lib/extensions/mspec/mspec/runner/actions/filter.rb', line 13 def initialize(=nil, descs=nil) @tags = Array() descs = Array(descs) @sfilter = descs.empty? ? nil : MatchFilter.new(nil, *descs) @tfilter = nil end |
Instance Method Details
#===(string) ⇒ Object
20 21 22 |
# File 'lib/extensions/mspec/mspec/runner/actions/filter.rb', line 20 def ===(string) @sfilter === string or @tfilter === string end |
#load ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/extensions/mspec/mspec/runner/actions/filter.rb', line 24 def load return if @tags.empty? desc = MSpec.(@tags).map { |t| t.description } return if desc.empty? @tfilter = MatchFilter.new(nil, *desc) end |
#register ⇒ Object
33 34 35 |
# File 'lib/extensions/mspec/mspec/runner/actions/filter.rb', line 33 def register MSpec.register :load, self end |
#unregister ⇒ Object
37 38 39 |
# File 'lib/extensions/mspec/mspec/runner/actions/filter.rb', line 37 def unregister MSpec.unregister :load, self end |