Add option to use a custom yaml mapping file
Adds an optional mapping-file
switch to TestFileFinder
executable.
Usage: tff [options] [...file_paths]
-f, --mapping-file FILE Use a custom test mapping file
The mapping-file
is a yaml file containing to entries to match file patterns to its test files. The patterns may include capturing groups to be used to identify the test file. For example:
mapping:
# maps `app/file.rb` to `spec/file_spec.rb`
- source: app/(.+)\.rb
test: spec/%s_spec.rb
# maps `db/schema.rb` to `spec/db/schema_spec.rb`
- source: db/schema.rb
test: spec/db/schema_spec.rb
# maps `ee/app/models/ee/user.rb` to `ee/spec/models/user_spec.rb`
- source: ee/app/(.*/)ee/(.+)\.rb
test: ee/spec/%s%s_spec.rb
Example usage:
$ tff -f tests.yml lib/test_file_finder/mapping.rb lib/test_file_finder/option_parser.rb | xargs bundle exec rspec
TestFileFinder::Mapping
.load
loads test_map file into a Mapping
with incorrect yaml
raises error
with incomplete mapping
rejects with error
#map
adds source file regex pattern and test file matcher to pattern matchers
when given a string pattern
adds string pattern to pattern matchers
#match
returns matching test file names
with multiple matching test files
returns all matching test file names
when the file does not match given pattern
returns nothing
with multiple matching mappings
returns all matching test file names
with matching subdirectory
returns nothing
#|
merges mapping with another mapping
with a repeated pattern
merges both matchers for the same pattern
TestFileFinder::OptionParser
--mapping-file FILE
is expected to eq "mapping.yml"
-f FILE
is expected to eq "mapping.yml"
Finished in 0.02352 seconds (files took 0.11094 seconds to load)
14 examples, 0 failures
Closes #8 (closed)
Edited by Albert Salim