-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guard is indispensable for TDD red/green coding. https://github.com/guard/guard#readme
- Loading branch information
Adam Spiers
committed
Nov 24, 2016
1 parent
8a46f27
commit 02f2c92
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/ruby | ||
# | ||
# More info at https://github.com/guard/guard#readme | ||
|
||
guard_opts = { | ||
cmd: "bundle exec rspec --fail-fast", | ||
all_on_start: true, | ||
all_after_pass: true, | ||
failed_mode: :focus | ||
} | ||
|
||
DEBUG = false | ||
|
||
def reload(target) | ||
puts "-> #{target}" if DEBUG | ||
target | ||
end | ||
|
||
def all_specs; reload "all_specs"; "spec" end | ||
def library_specs; reload "library_specs"; "spec/libraries" end | ||
def provider_specs; reload "provider_specs"; "spec/providers" end | ||
|
||
group :rspec do | ||
guard :rspec, guard_opts do | ||
watch('app/controllers/application_controller.rb') { | ||
"spec/controllers" | ||
} | ||
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | ||
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } | ||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | ||
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| | ||
[ | ||
"spec/routing/#{m[1]}_routing_spec.rb", | ||
"spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", | ||
"spec/acceptance/#{m[1]}_spec.rb" | ||
] | ||
} | ||
watch(%r{^Gemfile$}) { all_specs } | ||
watch(%r{^Gemfile.lock$}) { all_specs } | ||
watch(%r{^spec/spec_helper\.rb$}) { all_specs } | ||
watch(%r{^spec/helpers/.+\.rb$}) { all_specs } | ||
watch(%r{^spec/.+_spec\.rb$}) | ||
end | ||
end | ||
|
||
group :bundler do | ||
guard :bundler do | ||
watch("Gemfile") | ||
end | ||
end |