diff --git a/CHANGELOG.md b/CHANGELOG.md index aadf575..6851898 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/src/spectator/config/cli_arguments_applicator.cr b/src/spectator/config/cli_arguments_applicator.cr index 496fc1a..15c9f94 100644 --- a/src/spectator/config/cli_arguments_applicator.cr +++ b/src/spectator/config/cli_arguments_applicator.cr @@ -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 diff --git a/src/spectator/name_node_filter.cr b/src/spectator/name_node_filter.cr index 6d4e64a..c404246 100644 --- a/src/spectator/name_node_filter.cr +++ b/src/spectator/name_node_filter.cr @@ -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