Skip to content

Instantly share code, notes, and snippets.

@micgo
Created January 2, 2014 20:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micgo/8226787 to your computer and use it in GitHub Desktop.
Save micgo/8226787 to your computer and use it in GitHub Desktop.
Chefspec + Foodcritic + Test-Kitchen + Guard
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'kitchen' do
watch(%r{test/.+})
watch(%r{^recipes/(.+)\.rb$})
watch(%r{^attributes/(.+)\.rb$})
watch(%r{^files/(.+)})
watch(%r{^templates/(.+)})
watch(%r{^providers/(.+)\.rb})
watch(%r{^resources/(.+)\.rb})
end
guard "foodcritic", :cookbook_paths => ".", :all_on_start => false do
watch(%r{attributes/.+\.rb$})
watch(%r{providers/.+\.rb$})
watch(%r{recipes/.+\.rb$})
watch(%r{resources/.+\.rb$})
watch('metadata.rb')
end
guard :rspec, cmd: 'bundle exec rspec', :all_on_start => false, notification: false do
watch(%r{^spec/(.+)_spec\.rb$})
watch(%r{^(recipes)/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { 'spec' }
end
@biinari
Copy link

biinari commented Apr 13, 2016

Your watch for rspec recipes (line 24) uses the wrong capture group in the spec file. Could use a non-capturing group to fix:

  watch(%r{^(?:recipes)/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }

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