Created
October 8, 2020 10:44
-
-
Save mkldon/995e17c4ff46c77553c6f05dd0d49f22 to your computer and use it in GitHub Desktop.
run rspec tests for all changed files on branch
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
#!/usr/bin/ruby | |
changes = `git diff master --name-only`.split("\n") | |
puts "All changes:\n #{changes.join("\n ")}" | |
changes = changes.select { |s| s =~ /^app/ } | |
puts "Changed app files:\n #{changes.join("\n ")}" | |
tests = changes.map { |s| s.gsub(/^app/, "spec").gsub(/.rb$/, "_spec.rb") } | |
tests = tests.select { |s| File.exists?(s) } | |
puts "Test files:\n #{tests.join("\n ")}" | |
cmd = "zeus rspec #{tests.join(" ")}" | |
puts "Running\n #{cmd}" | |
exec cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment