Skip to content

Instantly share code, notes, and snippets.

@bramswenson
Last active June 12, 2016 16:01
Show Gist options
  • Save bramswenson/fc45a2c1b6dc3aa4c6740d115bd9ce68 to your computer and use it in GitHub Desktop.
Save bramswenson/fc45a2c1b6dc3aa4c6740d115bd9ce68 to your computer and use it in GitHub Desktop.
files: ./spec/**/*_spec.cr
run: crystal spec %file%
---
files: ./src/**/*.cr
run: crystal spec
---
files: ./shard.yml
run: crystal deps
def crystal_spec_runner(match)
n match[0], 'File Changed'
puts match[0] + ' File Changed'
spec_file = if match[0].start_with?("spec/")
match[0]
else
"spec/#{match[0].gsub('src/', '')[0..-4]}_spec.cr"
end
if File.exists?(spec_file)
puts %x( crystal spec #{spec_file} )
if $?.exitstatus == 0
puts "#{spec_file} success"
n match[0], "#{spec_file} success", :success
else
puts "#{spec_file} failed"
n match[0], "#{spec_file} failed", :failed
end
else
puts "#{spec_file} not found"
n match[0], "#{spec_file} not found", :pending
end
end
guard :shell do
watch(/src\/(.*).cr/) { |m| crystal_spec_runner(m) }
watch(/spec\/(.*)_spec.cr/) { |m| crystal_spec_runner(m) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment