Skip to content

Instantly share code, notes, and snippets.

@mkldon
Created October 8, 2020 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkldon/995e17c4ff46c77553c6f05dd0d49f22 to your computer and use it in GitHub Desktop.
Save mkldon/995e17c4ff46c77553c6f05dd0d49f22 to your computer and use it in GitHub Desktop.
run rspec tests for all changed files on branch
#!/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