1- package (default_visibility = ["//:__subpackages__" ])
2-
31load (
42 "@bazelruby_ruby_rules//ruby:defs.bzl" ,
53 "ruby_binary" ,
6- "ruby_library" ,
74 "ruby_rspec" ,
5+ "ruby_rubocop" ,
86 "ruby_test" ,
97)
108
11- filegroup (
12- name = "sources" ,
13- srcs = glob ([
14- "script.rb" ,
15- "lib/*.rb" ,
16- ]),
17- )
18-
19- filegroup (
20- name = "spec_sources" ,
21- srcs = glob ([
22- "spec/**/*.rb" ,
23- ]),
24- )
25-
26- ruby_library (
27- name = "lib" ,
28- srcs = [
29- ":sources" ,
30- ":spec_sources" ,
31- ],
32- deps = [
33- "@bundle//:awesome_print" ,
34- "@bundle//:colored2" ,
35- ],
36- )
9+ package (default_visibility = ["//:__subpackages__" ])
3710
3811ruby_binary (
3912 name = "bin" ,
4013 srcs = ["script.rb" ],
4114 main = "script.rb" ,
4215 deps = [
43- ":lib" ,
4416 "//lib:foo" ,
4517 "@bundle//:awesome_print" ,
46- "@bundle//:colored2" ,
47- ],
48- )
49-
50- ruby_binary (
51- name = "bin-all" ,
52- srcs = ["script.rb" ],
53- main = "script.rb" ,
54- deps = [
55- ":lib" ,
56- "//lib:foo" ,
57- "@bundle//:bin" ,
5818 ],
5919)
6020
6121# This is an example of the RSpec definition that uses autorun
6222# and points to spec_helper as the main spec file. It specifies
6323# which specs to run using the args.
24+
6425ruby_test (
65- name = "rspec-autorun " ,
26+ name = "all-specs " ,
6627 timeout = "short" ,
6728 srcs = [
68- ":sources" ,
69- ":spec_sources" ,
70- ],
71- args = [
72- "--format documentation" ,
73- "--force-color" ,
29+ "script.rb" ,
30+ "//lib:foo" ,
7431 ] + glob ([
7532 "spec/**/*.rb" ,
7633 ]),
77- main = "spec/spec_helper.rb" ,
78- rubyopt = ["-rrspec/autorun" ],
79- deps = [
80- "@bundle//:gems" ,
81- ],
82- )
83-
84- # This is a similar example, except instead of using rubyopt to load
85- # rspec, we execute rspec executable located in the bin folder under
86- # the bundle, accessible via @bundle//:bin/rspec
87- ruby_test (
88- name = "rspec-binary" ,
89- timeout = "short" ,
90- srcs = [
91- ":sources" ,
92- ":spec_sources" ,
93- "@bundle//:bin/rspec" ,
94- ],
9534 args = [
96- "--format documentation" ,
97- "--force-color" ,
9835 "spec" ,
9936 ],
10037 main = "@bundle//:bin/rspec" ,
10138 deps = [
10239 "@bundle//:awesome_print" ,
10340 "@bundle//:bin" ,
104- "@bundle//:colored2" ,
10541 "@bundle//:rspec" ,
10642 "@bundle//:rspec-its" ,
10743 ],
@@ -115,8 +51,8 @@ ruby_test(
11551ruby_rspec (
11652 name = "ruby-rspec-test" ,
11753 srcs = [
118- ":sources " ,
119- ":spec_sources " ,
54+ "script.rb " ,
55+ "//lib:foo " ,
12056 ],
12157 rspec_args = {
12258 # NOTE: the output is only visible with --test_output=streamed flag
@@ -127,26 +63,34 @@ ruby_rspec(
12763 ]),
12864 deps = [
12965 "@bundle//:awesome_print" ,
130- "@bundle//:colored2" ,
13166 ],
13267)
13368
13469ruby_binary (
135- name = "rubocop" ,
70+ name = "rubocop-bin " ,
13671 srcs = [
137- ".relaxed-rubocop-2.4.yml" ,
138- ".rubocop.yml" ,
139- ],
72+ "script.rb" ,
73+ "//lib:foo" ,
74+ ] + glob ([
75+ "spec/**/*.rb" ,
76+ ]),
14077 args = [
141- "-c" ,
142- ".rubocop.yml" ,
143- "-P" ,
144- "-D" ,
78+ "-- *.rb spec/*.rb lib/*.rb -a" ,
14579 ],
14680 main = "@bundle//:bin/rubocop" ,
14781 deps = [
148- ":lib" ,
14982 "//lib:foo" ,
15083 "@bundle//:bin" ,
15184 ],
15285)
86+
87+ # Rubocop rule
88+ # To check
89+ # bazel run rubocop -- -a
90+ ruby_rubocop (
91+ name = "rubocop" ,
92+ bin = "@bundle//:bin/rubocop" ,
93+ deps = [
94+ "@bundle//:rubocop" ,
95+ ],
96+ )
0 commit comments