forked from htty/htty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Guardfile
37 lines (30 loc) · 1.22 KB
/
Guardfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'guard/rspec/dsl'
debugger_gem = %w(pry-byebug).detect do |gem|
`bundle show #{gem} 2>&1 >/dev/null`
$?.success?
end
debugger_require = debugger_gem ? " --require #{debugger_gem}" : nil
guard :rspec, all_on_start: true,
all_after_pass: true,
cmd: "bundle exec rspec --format progress#{debugger_require}" do
dsl = Guard::RSpec::Dsl.new(self)
rspec, ruby = dsl.rspec, dsl.ruby
# RSpec files
watch('.rspec') { rspec.spec_dir }
watch rspec.spec_helper { rspec.spec_dir }
watch rspec.spec_support { rspec.spec_dir }
watch(%r{^spec/support}) { rspec.spec_dir } # This should not be necessary.
watch rspec.spec_files
# Run all specs when a shared spec changes.
watch(%r{^spec/.+_sharedspec\.rb$}) { rspec.spec_dir }
# Run all specs when the bundle changes.
watch('Gemfile.lock') { rspec.spec_dir }
watch(%r{^(.+)\.gemspec$}) { rspec.spec_dir }
# Ruby files
dsl.watch_spec_files_for ruby.lib_files
# Run the corresponding spec(s) (or all specs) when code changes.
watch(%r{^lib/(.+)\.rb$}) do |match|
corresponding_specs = Dir["spec/{integration,unit}/#{match[1]}_spec.rb"]
corresponding_specs.empty? ? rspec.spec_dir : corresponding_specs
end
end