mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Add support for guard and spring
guard encourages TDD behaviour through development iterations which include continuous testing. Coupling this with spring eliminates the cost of continually loading gems into a fresh environment every time the tests are run.
This commit is contained in:
parent
08d4bb848b
commit
ed10045fad
4 changed files with 124 additions and 5 deletions
64
Guardfile
Normal file
64
Guardfile
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/ruby
|
||||
#
|
||||
# More info at https://github.com/guard/guard#readme
|
||||
|
||||
guard_opts = {
|
||||
all_on_start: true,
|
||||
all_after_pass: true,
|
||||
cmd: 'spring rspec'
|
||||
}
|
||||
|
||||
def model_specs ; "spec/models" end
|
||||
|
||||
def model_spec(model)
|
||||
"spec/models/#{model}_spec.rb"
|
||||
end
|
||||
|
||||
def all_testunit_tests
|
||||
[
|
||||
model_tests,
|
||||
controller_tests,
|
||||
helper_tests,
|
||||
integration_tests,
|
||||
]
|
||||
end
|
||||
|
||||
def all_specs
|
||||
[
|
||||
model_specs,
|
||||
]
|
||||
end
|
||||
|
||||
def startup_guards
|
||||
watch(%r{^Gemfile$}) { yield }
|
||||
watch(%r{^Gemfile.lock$}) { yield }
|
||||
watch(%r{^config/routes.rb$}) { yield }
|
||||
watch(%r{^config/application\.rb$}) { yield }
|
||||
watch(%r{^config/environment\.rb$}) { yield }
|
||||
watch(%r{^config/environments/.+\.rb$}) { yield }
|
||||
watch(%r{^config/initializers/.+\.rb$}) { yield }
|
||||
watch(%r{^db/schema\.rb$}) { yield }
|
||||
watch(%r{^spec/spec_helper\.rb$}) { yield }
|
||||
end
|
||||
|
||||
def rspec_guards
|
||||
watch(%r{^spec/factories/.+\.rb$}) { all_specs }
|
||||
watch(%r{^spec/.+_spec\.rb$})
|
||||
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
||||
end
|
||||
|
||||
group :rspec do
|
||||
guard 'rspec', guard_opts do
|
||||
#startup_guards { all_specs }
|
||||
rspec_guards
|
||||
#all_specs
|
||||
end
|
||||
end
|
||||
|
||||
# group :bundler do
|
||||
# guard 'bundler' do
|
||||
# watch('Gemfile')
|
||||
# # Uncomment next line if Gemfile contain `gemspec' command
|
||||
# # watch(/^.+\.gemspec/)
|
||||
# end
|
||||
# end
|
||||
Loading…
Add table
Add a link
Reference in a new issue