forked from rmosolgo/graphql-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Guardfile
54 lines (48 loc) · 1.45 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# frozen_string_literal: true
guard :bundler do
watch("Gemfile")
# Uncomment next line if your Gemfile contains the `gemspec' command.
watch(/^.+\.gemspec/)
end
guard :minitest, test_file_patterns: ["*_spec.rb"] do
# with Minitest::Spec
watch(%r{^spec/(.*)_spec\.rb})
watch(%r{^lib/(.+)\.rb}) { |m|
# When a project file changes, run any of:
# - Corresponding `spec/` file
# - Corresponding `spec/` file
# for the file named in `test_via:`
to_run = []
matching_spec = "spec/#{m[1]}_spec.rb"
if File.exist?(matching_spec)
to_run << matching_spec
end
# If the file was deleted, it won't exist anymore
if File.exist?(m[0])
# Find a `# test_via:` macro to automatically run another test
body = File.read(m[0])
test_via_match = body.match(/test_via: (.*)/)
if test_via_match
test_via_path = test_via_match[1]
companion_file = Pathname.new(m[0] + "/../" + test_via_path)
.cleanpath
.to_s
.sub(/.rb/, "_spec.rb")
.sub("lib/", "spec/")
to_run << companion_file
end
end
# 0+ files
to_run
}
watch(%r{^spec/spec_helper\.rb}) { "spec" }
watch(%r{^spec/support/.*\.rb}) { "spec" }
end
guard "rake", task: "build_parser" do
watch("lib/graphql/language/parser.y")
watch("lib/graphql/language/lexer.rl")
end
guard :rubocop, all_on_start: false do
watch(%r{^spec/.*.\rb})
watch(%r{^lib/.*\.rb})
end