Skip to content

Instantly share code, notes, and snippets.

@jaydorsey
Created June 5, 2018 18:27
Show Gist options
  • Save jaydorsey/272db89fc54360aba2221487728e3b7c to your computer and use it in GitHub Desktop.
Save jaydorsey/272db89fc54360aba2221487728e3b7c to your computer and use it in GitHub Desktop.
Guard for exercism
# Append this alias to your .zshrc or .bashrc
#
# Run `guardme` from any exercise directory to start guard
# with your custom Guardfile
alias guardme="guard --guardfile ~/exercism/ruby/Guardfile"
# Place this file in ~/exercism/ruby
#
# This runs minitest, followed by rubocop
#
# https://paulfioravanti.com/blog/2018/01/11/setting-up-a-ruby-development-environment-for-exercism/
group :red_green_refactor, half_on_fail: true do
guard :minitest, cli: '--pride', test_folders: ['.'] do
# Re-test files when they're modified
watch(%r{\A.+_test\.rb\z}) { |m| "./#{m[1]}" }
# Run the test file of the file that was edited
watch(%r{\A(.+)(?<!_test)\.rb\z}) { |m| "./#{m[1]}_test.rb" }
end
guard :rubocop do
# Only run Rubocop over implementation files
# as test files are not written by students.
watch(%r{\A(.+)(?<!_test)\.rb\z})
watch(%r{(?:.+/)?\.rubocop\.yml\z}) { |m| File.dirname(m[0]) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment