Last active
June 4, 2018 09:34
-
-
Save odlp/58fb925ff65629ff502479860bd072cd to your computer and use it in GitHub Desktop.
Check test / spec files are named correctly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Checks test files are named "_spec.rb" to match the RSpec globs property | |
# defined in .circleci/config.yml. This will fail the build if there are test | |
# files which don't match the required pattern. | |
# Ignores first-level helper files (e.g. spec_helper.rb) and the spec/support, | |
# spec/factories, spec/shared_examples folders | |
set -eu | |
echo "Checking test files are named *_spec.rb to ensure being run on CI..." | |
TEST_FILE_PATTERN="_spec.rb" | |
findIncorrectTestFilenames() { | |
find spec -mindepth 2 \ | |
-type f -name "*.rb" \ | |
-not -path "spec/support/*" \ | |
-not -path "spec/factories/*" \ | |
-not -path "spec/shared_examples/*" \ | |
| grep "$TEST_FILE_PATTERN" --invert-match | |
} | |
if findIncorrectTestFilenames; then | |
echo "Rename the files as <name>$TEST_FILE_PATTERN or move to another directory" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment