Guardfile 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. guard :bundler do
  2. require 'guard/bundler'
  3. require 'guard/bundler/verify'
  4. helper = Guard::Bundler::Verify.new
  5. files = ['Gemfile']
  6. files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
  7. files.each { |file| watch(helper.real_path(file)) }
  8. end
  9. guard 'rails' do
  10. watch('Gemfile.lock')
  11. watch(%r{^(config|lib)/.*})
  12. end
  13. # Sidekiq files
  14. # guard 'sidekiq', :config => '../engine/config/sidekiq.yml' do
  15. # watch(%r{^workers/(.+)\.rb$})
  16. # watch(%r{^models/(.+)\.rb$})
  17. # end
  18. guard :rspec, cmd: "bundle exec rspec" do
  19. require "guard/rspec/dsl"
  20. dsl = Guard::RSpec::Dsl.new(self)
  21. # RSpec files
  22. rspec = dsl.rspec
  23. watch(rspec.spec_helper) { rspec.spec_dir }
  24. watch(rspec.spec_support) { rspec.spec_dir }
  25. watch(rspec.spec_files)
  26. # Ruby files
  27. ruby = dsl.ruby
  28. dsl.watch_spec_files_for(ruby.lib_files)
  29. # Rails files
  30. rails = dsl.rails(view_extensions: %w(erb haml slim))
  31. dsl.watch_spec_files_for(rails.app_files)
  32. dsl.watch_spec_files_for(rails.views)
  33. watch(rails.controllers) do |m|
  34. [
  35. rspec.spec.call("routing/#{m[1]}_routing"),
  36. rspec.spec.call("controllers/#{m[1]}_controller"),
  37. rspec.spec.call("features/#{m[1]}_spec")
  38. ]
  39. end
  40. # Rails config changes
  41. watch(rails.spec_helper) { rspec.spec_dir }
  42. watch(rails.routes) { "#{rspec.spec_dir}/routing" }
  43. watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
  44. # Capybara features specs
  45. watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
  46. watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
  47. # Turnip features and steps
  48. watch(%r{^spec/acceptance/(.+)\.feature$})
  49. watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
  50. Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
  51. end
  52. end