Skip to content

Commit 02f2c92

Browse files
author
Adam Spiers
committed
add guard environment
Guard is indispensable for TDD red/green coding. https://github.com/guard/guard#readme
1 parent 8a46f27 commit 02f2c92

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

crowbar_framework/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ unless ENV["PACKAGING"] && ENV["PACKAGING"] == "yes"
6363
gem "byebug", "~> 8.2.2"
6464
gem "derailed_benchmarks", "~> 1.3.0"
6565
gem "stackprof", "~> 0.2.8"
66+
gem "guard-rspec"
67+
gem "guard-bundler"
6668
end
6769

6870
group :test do

crowbar_framework/Guardfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/ruby
2+
#
3+
# More info at https://github.com/guard/guard#readme
4+
5+
guard_opts = {
6+
cmd: "bundle exec rspec --fail-fast",
7+
all_on_start: true,
8+
all_after_pass: true,
9+
failed_mode: :focus
10+
}
11+
12+
DEBUG = false
13+
14+
def reload(target)
15+
puts "-> #{target}" if DEBUG
16+
target
17+
end
18+
19+
def all_specs; reload "all_specs"; "spec" end
20+
def library_specs; reload "library_specs"; "spec/libraries" end
21+
def provider_specs; reload "provider_specs"; "spec/providers" end
22+
23+
group :rspec do
24+
guard :rspec, guard_opts do
25+
watch('app/controllers/application_controller.rb') {
26+
"spec/controllers"
27+
}
28+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
29+
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
30+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
31+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m|
32+
[
33+
"spec/routing/#{m[1]}_routing_spec.rb",
34+
"spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb",
35+
"spec/acceptance/#{m[1]}_spec.rb"
36+
]
37+
}
38+
watch(%r{^Gemfile$}) { all_specs }
39+
watch(%r{^Gemfile.lock$}) { all_specs }
40+
watch(%r{^spec/spec_helper\.rb$}) { all_specs }
41+
watch(%r{^spec/helpers/.+\.rb$}) { all_specs }
42+
watch(%r{^spec/.+_spec\.rb$})
43+
end
44+
end
45+
46+
group :bundler do
47+
guard :bundler do
48+
watch("Gemfile")
49+
end
50+
end

0 commit comments

Comments
 (0)