Skip to content

Instantly share code, notes, and snippets.

@dcadenas
Created October 16, 2012 16:31
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 dcadenas/3900388 to your computer and use it in GitHub Desktop.
Save dcadenas/3900388 to your computer and use it in GitHub Desktop.
Pre commit hook to avoid commiting badly named rspec files
#!/usr/bin/env ruby
test_dirs = %w[configurations
lib
modules
services
uploaders
controllers
helpers
mailers
presenters
validators
jobs
models
requests]
test_files_not_ending_with_spec = `find spec/{#{test_dirs.join(',')}} -type f|grep -v '_spec.rb$'`
if !test_files_not_ending_with_spec.split.empty?
puts "\e[33m>>> Please end these test files with _spec.rb before comitting:\e[0m"
puts test_files_not_ending_with_spec
exit 1
end
@dcadenas
Copy link
Author

Install it under .git/hooks and make it executable.
Example output:

▸ git commit -m "Blah blah"

Please end these test files with _spec.rb before comitting:
spec/services/customer_creation_service.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment