Last active
June 15, 2023 09:25
-
-
Save Lockyy/e4b1de7b0a4872423e4431bcd7dd957e to your computer and use it in GitHub Desktop.
Uses files-diff to retrieve a list of changed files and then filters it down to runnable specs then runs 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/bash | |
changedSpecFiles=$(files-diff | grep '^spec' | grep -v 'spec/support' | grep -v 'spec/factories') | |
joinedSpecFileNames=$($changedSpecFiles | tr "\n" " ") | |
spring rspec "$@" $($joinedSpecFileNames) |
Works under the assumption that anything not in spec/support or spec/factories is runnable.
Known bug: Will attempt to run unrunnable files in the root of spec if they've been changed.
I should probably update this so that it just hunts for anything ending in _spec.rb rather than trying to exclude specific folders.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
files-diff can be found at https://gist.github.com/Lockyy/4a5e96288edeb26b3dae17493803d62a