FAQ / knapsack_pro / General questions for knapsack_pro gem


Dir.glob accepts a single pattern or multiple test file patterns. When you provide multiple patterns, they must be wrapped by curly braces ({}) and separated by a comma with no space between the patterns, e.g.: {pattern1,pattern2,pattern3}. In the case of a single pattern, you should not wrap it in curly braces ({}).

When can this be useful? For instance, you could use complex patterns to find all model specs and all controller specs and run only them by defining KNAPSACK_PRO_TEST_FILE_PATTERN:


You can verify if the pattern works in Rails console:

$ bin/rails console
3.0.1 :001 > Dir.glob("{spec/models/**{,/*/**}/*_spec.rb,spec/controllers/**{,/*/**}/*_spec.rb}")

If you like, you can exclude specific tests with a KNAPSACK_PRO_TEST_FILE_EXCLUDE_PATTERN environment variable. For instance, you can exclude all API controller specs (note that we use a single pattern here, so no curly braces ({}) wrapping the pattern here):


Please use Rails console to verify that your Dir.glob pattern is valid for your test suite.

# General questions for knapsack_pro gem
See questions outside of this category

Start using Knapsack Pro

Sign up and speed up your tests.