2 # More info at https://github.com/guard/guard#readme
4 ## Uncomment and set this to only include directories you want to watch
5 # directories %w(app lib config test spec features) \
6 # .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
8 ## Note: if you are using the `directories` clause above and you are not
9 ## watching the project directory ('.'), then you will want to move
10 ## the Guardfile to a watched dir and symlink it back, e.g.
13 # $ mv Guardfile config/
14 # $ ln -s config/Guardfile .
16 # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
30 # less: :less, # uncomment if you want LESS stylesheets done in browser
33 rails_view_exts = %w[erb haml slim]
35 # file types LiveReload may optimize refresh for
36 compiled_exts = extensions.values.uniq
37 watch(%r{public/.+\.(#{compiled_exts * '|'})})
39 extensions.each do |ext, type|
42 (?:/assets/\w+/(?<path>[^.]+) # path+base without extension
43 (?<ext>\.#{ext})) # matching extension (must be first encountered)
44 (?:\.\w+|$) # other extensions
47 "/assets/#{path}.#{type}"
51 # file needing a full reload of the page anyway
52 watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$})
53 watch(%r{app/helpers/.+\.rb})
54 watch(%r{config/locales/.+\.yml})
59 # Note: The cmd option is now required due to the increasing number of ways
60 # rspec may be run, below are examples of the most common uses.
61 # * bundler: 'bundle exec rspec'
62 # * bundler binstubs: 'bin/rspec'
63 # * spring: 'bin/rspec' (This will use spring if running and you have
64 # installed the spring binstubs per the docs)
65 # * zeus: 'zeus rspec' (requires the server to be started separately)
66 # * 'just' rspec: 'rspec'
68 guard :rspec, cmd: "bin/rspec" do
69 require "guard/rspec/dsl"
70 dsl = Guard::RSpec::Dsl.new(self)
72 # Feel free to open issues for suggestions and improvements
76 watch(rspec.spec_helper) { rspec.spec_dir }
77 watch(rspec.spec_support) { rspec.spec_dir }
78 watch(rspec.spec_files)
82 dsl.watch_spec_files_for(ruby.lib_files)
85 rails = dsl.rails(view_extensions: %w[erb haml slim])
86 dsl.watch_spec_files_for(rails.app_files)
87 dsl.watch_spec_files_for(rails.views)
89 watch(rails.controllers) do |m|
91 rspec.spec.call("routing/#{m[1]}_routing"),
92 rspec.spec.call("controllers/#{m[1]}_controller"),
93 rspec.spec.call("acceptance/#{m[1]}")
97 # Rails config changes
98 watch(rails.spec_helper) { rspec.spec_dir }
99 watch(rails.routes) { "#{rspec.spec_dir}/routing" }
100 watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
102 # Capybara features specs
103 watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
104 watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
106 # Turnip features and steps
107 watch(%r{^spec/acceptance/(.+)\.feature$})
108 watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
109 Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
112 watch(%r{^spec/system/(.+)\.spec\.rb})