Change `-e` to use partial instead of exact match

Fixes https://gitlab.com/arctic-fox/spectator/-/issues/71
Fixes https://github.com/icy-arctic-fox/spectator/issues/45
This commit is contained in:
Michael Miller 2022-08-07 15:20:17 -06:00
parent 17a3ca3ac7
commit b5c61f9003
No known key found for this signature in database
GPG Key ID: 32B47AE8F388A1FF
3 changed files with 5 additions and 2 deletions

View File

@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- `expect_raises` with block and no arguments produces compilation error. [#77](https://gitlab.com/arctic-fox/spectator/-/issues/77)
### Changed
- `-e` (`--example`) CLI option performs a partial match instead of exact match. [#71](https://gitlab.com/arctic-fox/spectator/-/issues/71) [#45](https://github.com/icy-arctic-fox/spectator/issues/45)
## [0.11.1] - 2022-07-18
### Fixed
- Workaround nilable type issue with memoized value. [#76](https://gitlab.com/arctic-fox/spectator/-/issues/76)

View File

@ -112,7 +112,7 @@ module Spectator
# Adds the example filter option to the parser.
private def example_option(parser, builder)
parser.on("-e", "--example STRING", "Run examples whose full nested names include STRING") do |pattern|
Log.debug { "Filtering for examples named '#{pattern}' (-e '#{pattern}')" }
Log.debug { "Filtering for examples containing '#{pattern}' (-e '#{pattern}')" }
filter = NameNodeFilter.new(pattern)
builder.add_node_filter(filter)
end

View File

@ -9,7 +9,7 @@ module Spectator
# Checks whether the node satisfies the filter.
def includes?(node) : Bool
@name == node.to_s
node.to_s.includes?(@name)
end
end
end