-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathBUILD.bazel
More file actions
96 lines (89 loc) · 2.01 KB
/
BUILD.bazel
File metadata and controls
96 lines (89 loc) · 2.01 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
load(
"@bazelruby_rules_ruby//ruby:defs.bzl",
"ruby_binary",
"ruby_rspec",
"ruby_rubocop",
"ruby_test",
)
package(default_visibility = ["//:__subpackages__"])
ruby_binary(
name = "bin",
srcs = ["script.rb"],
main = "script.rb",
deps = [
"//lib:foo",
"@bundle//:awesome_print",
],
)
# This is an example of the RSpec definition that uses autorun
# and points to spec_helper as the main spec file. It specifies
# which specs to run using the args.
ruby_test(
name = "all-specs",
timeout = "short",
srcs = [
"script.rb",
"//lib:foo",
] + glob([
"spec/**/*.rb",
]),
args = [
"spec",
],
main = "@bundle//:bin/rspec",
deps = [
"@bundle//:awesome_print",
"@bundle//:bin",
"@bundle//:rspec",
"@bundle//:rspec-its",
],
)
# Finally, this is the short version of the same thing, expressed
# via the ruby_rspec_test rule that does what the above example
# shows but encapsulated in the rule itself. It adds rspec and rspec-its
# gems to the dependency list, executes bin/rspec and passes spec_targets
# as arguments to rspec.
ruby_rspec(
name = "ruby-rspec-test",
srcs = [
"script.rb",
"//lib:foo",
],
rspec_args = {
# NOTE: the output is only visible with --test_output=streamed flag
"--format": "progress", # this is how we can override rspec output format
},
specs = glob([
"spec/**/*.rb",
]),
deps = [
"@bundle//:awesome_print",
],
)
ruby_binary(
name = "rubocop-bin",
srcs = [
"script.rb",
"//lib:foo",
] + glob([
"spec/**/*.rb",
]),
args = [
"-- *.rb spec/*.rb lib/*.rb -a",
],
main = "@bundle//:bin/rubocop",
deps = [
"//lib:foo",
"@bundle//:bin",
],
)
# Rubocop rule
# To check
# bazel run rubocop -- -a
ruby_rubocop(
name = "rubocop",
bin = "@bundle//:bin/rubocop",
deps = [
"@bundle//:rubocop",
],
)