Class: CukeSlicer::Slicer
- Inherits:
-
Object
- Object
- CukeSlicer::Slicer
- Defined in:
- lib/cuke_slicer/slicer.rb
Overview
The object responsible for slicing up a Cucumber test suite into discrete test cases.
Class Method Summary collapse
-
.known_filters ⇒ Object
The filtering options that are currently supported by the slicer.
Instance Method Summary collapse
-
#slice(target, filters = {}, format, &block) ⇒ Object
Slices up the given location into individual test cases.
Class Method Details
.known_filters ⇒ Object
The filtering options that are currently supported by the slicer.
48 49 50 51 52 53 |
# File 'lib/cuke_slicer/slicer.rb', line 48 def self.known_filters %i[excluded_tags included_tags excluded_paths included_paths] end |
Instance Method Details
#slice(target, filters = {}, format, &block) ⇒ Object
Slices up the given location into individual test cases.
The location chosen for slicing can be a file or directory path. Optional filters can be provided in order to ignore certain kinds of test cases. See #known_filters for the available option types. Most options are either a string or regular expression, although arrays of the same can be given instead if more than one filter is desired.
A block can be provided as a filter which can allow for maximal filtering flexibility. Note, however, that this exposes the underlying modeling objects and knowledge of how they work is then required to make good use of the filter.
Finally, the test cases can be provided as a collection of file:line strings or as a collection of the object types used to represent test cases by the underlying modeling library.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cuke_slicer/slicer.rb', line 28 def slice(target, filters = {}, format, &block) validate_target(target) validate_filters(filters) validate_format(format) begin target = File.directory?(target) ? CukeModeler::Directory.new(target) : CukeModeler::FeatureFile.new(target) rescue => e raise e unless e. =~ /lexing|parsing/i raise(ArgumentError, "A syntax or lexing problem was encountered while trying to parse #{target}") end if target.is_a?(CukeModeler::Directory) DirectoryExtractor.new.extract(target, filters, format, &block) else FileExtractor.new.extract(target, filters, format, &block) end end |