Created
May 18, 2024 18:47
This script identifies changed spec files in a Git repository and runs RSpec tests on them.
This file contains 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