Created
May 18, 2024 18:47
-
-
Save barelyknown/a597f500bf0655153c44576dfa427bf6 to your computer and use it in GitHub Desktop.
This script identifies changed spec files in a Git repository and runs RSpec tests on them.
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/zsh | |
# Step 1: Get the list of changed files | |
changed_files=$(git diff --name-only master) | |
# Step 2: Initialize an array for spec files | |
spec_files=() | |
# Step 3: Populate the array with spec files | |
while IFS= read -r file; do | |
spec_files+=("$file") | |
done < <(echo "$changed_files" | grep -E '_spec\.rb$' | grep -E '^spec/') | |
# Step 4: Run RSpec on the filtered spec files | |
bin/rspec "${spec_files[@]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment