Skip to content
代码片段 群组 项目
未验证 提交 09d8ae14 编辑于 作者: Andreas Brandl's avatar Andreas Brandl
浏览文件

Add guard to automatically run tests

This adds guard to automatically run relevant tests on file save. It can
be run with `bundle exec guard`.
上级 23daa419
No related branches found
No related tags found
无相关合并请求
...@@ -411,6 +411,7 @@ group :test do ...@@ -411,6 +411,7 @@ group :test do
gem 'concurrent-ruby', '~> 1.1' gem 'concurrent-ruby', '~> 1.1'
gem 'test-prof', '~> 0.10.0' gem 'test-prof', '~> 0.10.0'
gem 'rspec_junit_formatter' gem 'rspec_junit_formatter'
gem 'guard-rspec'
end end
gem 'octokit', '~> 4.9' gem 'octokit', '~> 4.9'
......
...@@ -446,6 +446,20 @@ GEM ...@@ -446,6 +446,20 @@ GEM
googleapis-common-protos-types (~> 1.0) googleapis-common-protos-types (~> 1.0)
gssapi (1.2.0) gssapi (1.2.0)
ffi (>= 1.0.1) ffi (>= 1.0.1)
guard (2.15.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
guard-compat (1.2.1)
guard-rspec (4.7.3)
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
haml (5.0.4) haml (5.0.4)
temple (>= 0.8.0) temple (>= 0.8.0)
tilt tilt
...@@ -561,6 +575,10 @@ GEM ...@@ -561,6 +575,10 @@ GEM
xml-simple xml-simple
licensee (8.9.2) licensee (8.9.2)
rugged (~> 0.24) rugged (~> 0.24)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
locale (2.1.2) locale (2.1.2)
lograge (0.10.0) lograge (0.10.0)
actionpack (>= 4) actionpack (>= 4)
...@@ -570,6 +588,7 @@ GEM ...@@ -570,6 +588,7 @@ GEM
loofah (2.3.1) loofah (2.3.1)
crass (~> 1.0.2) crass (~> 1.0.2)
nokogiri (>= 1.5.9) nokogiri (>= 1.5.9)
lumberjack (1.0.13)
mail (2.7.1) mail (2.7.1)
mini_mime (>= 0.1.1) mini_mime (>= 0.1.1)
mail_room (0.9.1) mail_room (0.9.1)
...@@ -598,6 +617,7 @@ GEM ...@@ -598,6 +617,7 @@ GEM
mustermann (~> 1.0.0) mustermann (~> 1.0.0)
nakayoshi_fork (0.0.4) nakayoshi_fork (0.0.4)
nap (1.1.0) nap (1.1.0)
nenv (0.3.0)
net-ldap (0.16.0) net-ldap (0.16.0)
net-ntp (2.1.3) net-ntp (2.1.3)
net-ssh (5.2.0) net-ssh (5.2.0)
...@@ -608,6 +628,9 @@ GEM ...@@ -608,6 +628,9 @@ GEM
mini_portile2 (~> 2.4.0) mini_portile2 (~> 2.4.0)
nokogumbo (1.5.0) nokogumbo (1.5.0)
nokogiri nokogiri
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
numerizer (0.1.1) numerizer (0.1.1)
oauth (0.5.4) oauth (0.5.4)
oauth2 (1.4.1) oauth2 (1.4.1)
...@@ -898,6 +921,7 @@ GEM ...@@ -898,6 +921,7 @@ GEM
ruby-progressbar (1.10.1) ruby-progressbar (1.10.1)
ruby-saml (1.7.2) ruby-saml (1.7.2)
nokogiri (>= 1.5.10) nokogiri (>= 1.5.10)
ruby_dep (1.5.0)
ruby_parser (3.13.1) ruby_parser (3.13.1)
sexp_processor (~> 4.9) sexp_processor (~> 4.9)
rubyntlm (0.6.2) rubyntlm (0.6.2)
...@@ -939,6 +963,7 @@ GEM ...@@ -939,6 +963,7 @@ GEM
faraday (>= 0.7.6, < 1.0) faraday (>= 0.7.6, < 1.0)
settingslogic (2.0.9) settingslogic (2.0.9)
sexp_processor (4.12.0) sexp_processor (4.12.0)
shellany (0.0.1)
shoulda-matchers (4.0.1) shoulda-matchers (4.0.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
sidekiq (5.2.7) sidekiq (5.2.7)
...@@ -1193,6 +1218,7 @@ DEPENDENCIES ...@@ -1193,6 +1218,7 @@ DEPENDENCIES
graphql-docs (~> 1.6.0) graphql-docs (~> 1.6.0)
grpc (~> 1.24.0) grpc (~> 1.24.0)
gssapi gssapi
guard-rspec
haml_lint (~> 0.31.0) haml_lint (~> 0.31.0)
hamlit (~> 2.8.8) hamlit (~> 2.8.8)
hangouts-chat (~> 0.0.5) hangouts-chat (~> 0.0.5)
......
# frozen_string_literal: true
# More info at https://github.com/guard/guard#readme
# If using spring, change command to "spring rspec"
guard :rspec, cmd: "bundle exec rspec" do
require "guard/rspec/dsl"
dsl = Guard::RSpec::Dsl.new(self)
directories %w(app ee lib spec)
# RSpec files
rspec = dsl.rspec
watch(rspec.spec_helper) { rspec.spec_dir }
watch(rspec.spec_support) { rspec.spec_dir }
watch(rspec.spec_files)
# Ruby files
ruby = dsl.ruby
dsl.watch_spec_files_for(ruby.lib_files)
# Rails files
rails = dsl.rails(view_extensions: %w(erb haml slim))
dsl.watch_spec_files_for(rails.app_files)
dsl.watch_spec_files_for(rails.views)
watch(rails.controllers) do |m|
[
rspec.spec.call("routing/#{m[1]}_routing"),
rspec.spec.call("controllers/#{m[1]}_controller")
]
end
# Rails config changes
watch(rails.spec_helper) { rspec.spec_dir }
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
# Capybara features specs
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
end
...@@ -44,6 +44,20 @@ bundle exec rspec ...@@ -44,6 +44,20 @@ bundle exec rspec
bundle exec rspec spec/[path]/[to]/[spec].rb bundle exec rspec spec/[path]/[to]/[spec].rb
``` ```
Use [guard](https://github.com/guard/guard) to continuously monitor for changes and only run matching tests:
```sh
bundle exec guard
```
When using spring and guard together, consider adjusting Guardfile:
```ruby
guard :rspec, cmd: "spring rspec" do
# ...
end
```
### General guidelines ### General guidelines
- Use a single, top-level `describe ClassName` block. - Use a single, top-level `describe ClassName` block.
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册