Created
May 19, 2017 15:24
-
-
Save amyroi/ff79ce617aa05624e56c257981f1a00b to your computer and use it in GitHub Desktop.
Guardfile target submodule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample Guardfile use options chdir | |
paths = %w(spec submodule/spec) | |
dirs = %w(./ submodule/) | |
dirs.each do |dir| | |
guard :rspec, cmd: 'bin/spring rspec', chdir: dir do | |
require 'guard/rspec/dsl' | |
dsl = Guard::RSpec::Dsl.new(self) | |
# RSpec files | |
rspec = dsl.rspec | |
watch(rspec.spec_helper) { rspec.spec_dir } | |
watch(rspec.spec_support) { rspec.spec_dir } | |
watch(rspec.spec_files) | |
watch(%r{#{dir}spec/.+_spec\.rb}) | |
watch(%r{#{dir}app/(.+)\.rb}) { |m| "#{dir}spec/#{m[1]}_spec.rb" } | |
# Ruby files | |
ruby = dsl.ruby | |
dsl.watch_spec_files_for(ruby.lib_files) | |
# Rails files | |
rails = dsl.rails(view_extensions: %w(erb haml slim)) | |
dsl.watch_spec_files_for(rails.app_files) | |
dsl.watch_spec_files_for(rails.views) | |
watch(rails.controllers) do |m| | |
[ | |
rspec.spec.call("#{dir}routing/#{m[1]}_routing"), | |
rspec.spec.call("#{dir}controllers/#{m[1]}_controller"), | |
rspec.spec.call("#{dir}acceptance/#{m[1]}") | |
] | |
end | |
# Rails config changes | |
watch(rails.spec_helper) { rspec.spec_dir } | |
watch(rails.routes) { "#{rspec.spec_dir}/routing" } | |
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" } | |
# Capybara features specs | |
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") } | |
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment