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
13
Gemfile
13
Gemfile
|
|
@ -79,8 +79,11 @@ gem 'sqlite3', group: [:development]
|
|||
gem 'letter_opener', group: [:development]
|
||||
|
||||
# Use rspec and capybara as testing framework
|
||||
gem 'rspec-rails', '~> 3.0.0.beta', group: [:test]
|
||||
gem 'capybara', group: [:test]
|
||||
group :development, :test do
|
||||
gem 'rspec', '>= 3.0.0.beta'
|
||||
gem 'rspec-rails', '>= 3.0.0.beta'
|
||||
gem 'capybara'
|
||||
end
|
||||
|
||||
# FIXME: We should use http://weblog.rubyonrails.org/2012/3/21/strong-parameters/
|
||||
gem 'protected_attributes'
|
||||
|
|
@ -90,3 +93,9 @@ gem 'rdoc-generator-fivefish'
|
|||
|
||||
# We use factory_girl for seeds
|
||||
gem 'factory_girl_rails'
|
||||
|
||||
# Use guard and spring for testing in development
|
||||
group :development do
|
||||
gem 'guard-rspec', '~> 4.2.8'
|
||||
gem 'spring-commands-rspec'
|
||||
end
|
||||
|
|
|
|||
46
Gemfile.lock
46
Gemfile.lock
|
|
@ -55,11 +55,17 @@ GEM
|
|||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (~> 2.0)
|
||||
celluloid (0.15.2)
|
||||
timers (~> 1.1.0)
|
||||
celluloid-io (0.15.0)
|
||||
celluloid (>= 0.15.0)
|
||||
nio4r (>= 0.5.0)
|
||||
climate_control (0.0.3)
|
||||
activesupport (>= 3.0)
|
||||
cocaine (0.5.4)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
cocoon (1.2.6)
|
||||
coderay (1.1.0)
|
||||
coffee-rails (4.0.1)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
|
|
@ -90,11 +96,22 @@ GEM
|
|||
factory_girl_rails (4.4.1)
|
||||
factory_girl (~> 4.4.0)
|
||||
railties (>= 3.0.0)
|
||||
ffi (1.9.3)
|
||||
formatador (0.2.4)
|
||||
formtastic (2.3.0.rc3)
|
||||
actionpack (>= 3.0)
|
||||
formtastic-bootstrap (3.0.0)
|
||||
formtastic (>= 2.2)
|
||||
gravtastic (3.2.6)
|
||||
guard (2.6.0)
|
||||
formatador (>= 0.2.4)
|
||||
listen (~> 2.7)
|
||||
lumberjack (~> 1.0)
|
||||
pry (>= 0.9.12)
|
||||
thor (>= 0.18.1)
|
||||
guard-rspec (4.2.8)
|
||||
guard (~> 2.1)
|
||||
rspec (>= 2.14, < 4.0)
|
||||
haml (4.0.5)
|
||||
tilt
|
||||
haml-rails (0.5.3)
|
||||
|
|
@ -123,15 +140,23 @@ GEM
|
|||
addressable (~> 2.3)
|
||||
letter_opener (1.2.0)
|
||||
launchy (~> 2.2)
|
||||
listen (2.7.2)
|
||||
celluloid (>= 0.15.2)
|
||||
celluloid-io (>= 0.15.0)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
loggability (0.11.0)
|
||||
lumberjack (1.0.5)
|
||||
mail (2.5.4)
|
||||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
method_source (0.8.2)
|
||||
mime-types (1.25.1)
|
||||
mini_portile (0.5.3)
|
||||
minitest (5.3.3)
|
||||
multi_json (1.9.2)
|
||||
mysql2 (0.3.15)
|
||||
nio4r (1.0.0)
|
||||
nokogiri (1.6.1)
|
||||
mini_portile (~> 0.5.0)
|
||||
orm_adapter (0.5.0)
|
||||
|
|
@ -153,6 +178,10 @@ GEM
|
|||
railties (>= 3.0.0)
|
||||
protected_attributes (1.0.7)
|
||||
activemodel (>= 4.0.1, < 5.0)
|
||||
pry (0.9.12.6)
|
||||
coderay (~> 1.0)
|
||||
method_source (~> 0.8)
|
||||
slop (~> 3.4)
|
||||
rack (1.5.2)
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
|
|
@ -174,6 +203,9 @@ GEM
|
|||
rake (>= 0.8.7)
|
||||
thor (>= 0.18.1, < 2.0)
|
||||
rake (10.3.1)
|
||||
rb-fsevent (0.9.4)
|
||||
rb-inotify (0.9.4)
|
||||
ffi (>= 0.5.0)
|
||||
rdoc (4.1.1)
|
||||
json (~> 1.4)
|
||||
rdoc-generator-fivefish (0.1.0)
|
||||
|
|
@ -183,6 +215,10 @@ GEM
|
|||
yajl-ruby (~> 1.1)
|
||||
rest-client (1.6.7)
|
||||
mime-types (>= 1.16)
|
||||
rspec (3.0.0.beta2)
|
||||
rspec-core (= 3.0.0.beta2)
|
||||
rspec-expectations (= 3.0.0.beta2)
|
||||
rspec-mocks (= 3.0.0.beta2)
|
||||
rspec-collection_matchers (0.0.4)
|
||||
rspec-expectations (>= 2.99.0.beta1)
|
||||
rspec-core (3.0.0.beta2)
|
||||
|
|
@ -215,6 +251,10 @@ GEM
|
|||
multi_json
|
||||
simplecov-html (~> 0.8.0)
|
||||
simplecov-html (0.8.0)
|
||||
slop (3.5.0)
|
||||
spring (1.1.2)
|
||||
spring-commands-rspec (1.0.2)
|
||||
spring (>= 0.9.1)
|
||||
sprockets (2.11.0)
|
||||
hike (~> 1.2)
|
||||
multi_json (~> 1.0)
|
||||
|
|
@ -230,6 +270,7 @@ GEM
|
|||
thor (0.19.1)
|
||||
thread_safe (0.3.3)
|
||||
tilt (1.4.1)
|
||||
timers (1.1.0)
|
||||
tins (1.1.0)
|
||||
transitions (0.1.12)
|
||||
treetop (1.4.15)
|
||||
|
|
@ -267,6 +308,7 @@ DEPENDENCIES
|
|||
formtastic (~> 2.3.0.rc3)
|
||||
formtastic-bootstrap
|
||||
gravtastic
|
||||
guard-rspec (~> 4.2.8)
|
||||
haml-rails
|
||||
hoptoad_notifier (~> 2.3)
|
||||
jquery-fileupload-rails
|
||||
|
|
@ -282,8 +324,10 @@ DEPENDENCIES
|
|||
rails (~> 4.1)
|
||||
rails-observers
|
||||
rdoc-generator-fivefish
|
||||
rspec-rails (~> 3.0.0.beta)
|
||||
rspec (>= 3.0.0.beta)
|
||||
rspec-rails (>= 3.0.0.beta)
|
||||
sass-rails (>= 4.0.2)
|
||||
spring-commands-rspec
|
||||
sqlite3
|
||||
transitions
|
||||
turbolinks
|
||||
|
|
|
|||
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
|
||||
|
|
@ -51,7 +51,9 @@ xdg-open doc/app/index.html
|
|||
```
|
||||
|
||||
## Testing
|
||||
We are using [rspec](http://rspec.info/)+[capybara](http://jnicklas.github.io/capybara/)+[factory girl](https://github.com/thoughtbot/factory_girl) as test suite. You *should* run it, whenever you change something, with
|
||||
We are using [rspec](http://rspec.info/)+[capybara](http://jnicklas.github.io/capybara/)+[factory girl](https://github.com/thoughtbot/factory_girl) to build test suite. You *should* run it continuously when you are developing, via:
|
||||
```
|
||||
bundle exec rake rspec
|
||||
bundle exec guard
|
||||
```
|
||||
This uses [spring](https://github.com/rails/spring) to provide a
|
||||
[fast feedback loop for the red/green cycle](http://bitzesty.com/blog/2013/05/enable-tdd-with-faster-ruby-on-rails-stack-reloading/).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue