自动化测试环境

This commit is contained in:
yanxd 2014-07-14 16:11:38 +08:00
parent fd5747f4dc
commit 14f1ad63d2
5 changed files with 129 additions and 63 deletions

17
Gemfile
View File

@ -19,13 +19,6 @@ gem 'acts-as-taggable-on', '2.4.1'
group :development do group :development do
gem 'better_errors', path: 'lib/better_errors' gem 'better_errors', path: 'lib/better_errors'
gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler'
gem "guard-rails"
gem 'guard-minitest'
gem 'guard-spork'
if ENV['PRY']
gem 'pry'
gem 'pry-nav'
end
end end
group :test do group :test do
@ -36,6 +29,16 @@ group :test do
gem 'nokogiri', '< 1.6.0' gem 'nokogiri', '< 1.6.0'
end end
group :development, :test do
gem "guard-rails"
gem 'spork-testunit'
gem 'guard-spork'
gem 'guard-test', '~> 1.0.0'
gem 'ruby-prof'
gem 'pry'
gem 'pry-nav'
end
# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.

View File

@ -51,7 +51,7 @@ GEM
multi_json (~> 1.0) multi_json (~> 1.0)
acts-as-taggable-on (2.4.1) acts-as-taggable-on (2.4.1)
rails (>= 3, < 5) rails (>= 3, < 5)
arel (3.0.2) arel (3.0.3)
builder (3.0.0) builder (3.0.0)
capybara (2.0.3) capybara (2.0.3)
mime-types (>= 1.16) mime-types (>= 1.16)
@ -72,13 +72,13 @@ GEM
coffee-rails (3.2.2) coffee-rails (3.2.2)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
railties (~> 3.2.0) railties (~> 3.2.0)
coffee-script (2.2.0) coffee-script (2.3.0)
coffee-script-source coffee-script-source
execjs execjs
coffee-script-source (1.7.0) coffee-script-source (1.7.1)
erubis (2.7.0) erubis (2.7.0)
execjs (2.0.2) execjs (2.2.1)
fastercsv (1.5.0) fastercsv (1.5.5)
ffi (1.9.3) ffi (1.9.3)
ffi (1.9.3-x86-mingw32) ffi (1.9.3-x86-mingw32)
formatador (0.2.5) formatador (0.2.5)
@ -88,26 +88,28 @@ GEM
lumberjack (~> 1.0) lumberjack (~> 1.0)
pry (>= 0.9.12) pry (>= 0.9.12)
thor (>= 0.18.1) thor (>= 0.18.1)
guard-minitest (2.3.1)
guard (~> 2.0)
minitest (>= 3.0)
guard-rails (0.5.2) guard-rails (0.5.2)
guard (~> 2.0) guard (~> 2.0)
guard-spork (1.5.1) guard-spork (1.5.1)
childprocess (>= 0.2.3) childprocess (>= 0.2.3)
guard (>= 1.1) guard (>= 1.1)
spork (>= 0.8.4) spork (>= 0.8.4)
guard-test (1.0.0)
guard (>= 1.8)
test-unit (~> 2.2)
hike (1.2.3) hike (1.2.3)
htmlentities (4.3.2) htmlentities (4.3.2)
i18n (0.6.1) i18n (0.6.1)
iconv (1.0.4)
journey (1.0.4) journey (1.0.4)
jquery-rails (2.0.3) jquery-rails (2.0.3)
railties (>= 3.1.0, < 5.0) railties (>= 3.1.0, < 5.0)
thor (~> 0.14) thor (~> 0.14)
json (1.8.0) json (1.8.1)
kaminari (0.16.1) kaminari (0.16.1)
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
libv8 (3.16.14.3)
listen (2.7.9) listen (2.7.9)
celluloid (>= 0.15.2) celluloid (>= 0.15.2)
rb-fsevent (>= 0.9.3) rb-fsevent (>= 0.9.3)
@ -118,11 +120,10 @@ GEM
treetop (~> 1.4.8) treetop (~> 1.4.8)
metaclass (0.0.4) metaclass (0.0.4)
method_source (0.8.2) method_source (0.8.2)
mime-types (1.23) mime-types (1.25.1)
minitest (5.4.0)
mocha (0.13.3) mocha (0.13.3)
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
multi_json (1.7.6) multi_json (1.10.1)
mysql2 (0.3.11) mysql2 (0.3.11)
mysql2 (0.3.11-x86-mingw32) mysql2 (0.3.11-x86-mingw32)
net-ldap (0.3.1) net-ldap (0.3.1)
@ -133,7 +134,7 @@ GEM
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
cocaine (~> 0.5.3) cocaine (~> 0.5.3)
mime-types mime-types
polyglot (0.3.3) polyglot (0.3.5)
pry (0.9.12.6) pry (0.9.12.6)
coderay (~> 1.0) coderay (~> 1.0)
method_source (~> 0.8) method_source (~> 0.8)
@ -148,12 +149,12 @@ GEM
rack (1.4.5) rack (1.4.5)
rack-cache (1.2) rack-cache (1.2)
rack (>= 0.4) rack (>= 0.4)
rack-openid (1.3.1) rack-openid (1.4.2)
rack (>= 1.1.0) rack (>= 1.1.0)
ruby-openid (>= 2.1.8) ruby-openid (>= 2.1.8)
rack-raw-upload (1.1.1) rack-raw-upload (1.1.1)
multi_json multi_json
rack-ssl (1.3.3) rack-ssl (1.3.4)
rack rack
rack-test (0.6.2) rack-test (0.6.2)
rack (>= 1.0) rack (>= 1.0)
@ -178,6 +179,7 @@ GEM
ffi (>= 0.5.0) ffi (>= 0.5.0)
rdoc (3.12.2) rdoc (3.12.2)
json (~> 1.4) json (~> 1.4)
ref (1.0.5)
rich (1.4.6) rich (1.4.6)
jquery-rails jquery-rails
kaminari kaminari
@ -188,8 +190,9 @@ GEM
sass-rails sass-rails
rmagick (2.13.2) rmagick (2.13.2)
ruby-openid (2.1.8) ruby-openid (2.1.8)
rubyzip (1.1.4) ruby-prof (0.15.1)
sass (3.2.14) rubyzip (1.1.6)
sass (3.3.10)
sass-rails (3.2.6) sass-rails (3.2.6)
railties (~> 3.2.0) railties (~> 3.2.0)
sass (>= 3.1.10) sass (>= 3.1.10)
@ -207,27 +210,36 @@ GEM
activesupport (>= 3.0.0) activesupport (>= 3.0.0)
slop (3.5.0) slop (3.5.0)
spork (0.9.2) spork (0.9.2)
spork-testunit (0.0.8)
spork (>= 0.6.0)
sprockets (2.2.2) sprockets (2.2.2)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
thor (0.18.1) test-unit (2.5.5)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
tilt (1.4.1) tilt (1.4.1)
timers (1.1.0) timers (1.1.0)
treetop (1.4.14) treetop (1.4.15)
polyglot polyglot
polyglot (>= 0.3.1) polyglot (>= 0.3.1)
tzinfo (0.3.37) tzinfo (0.3.40)
uglifier (2.4.0) uglifier (2.5.1)
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
websocket (1.0.7) websocket (1.0.7)
win32console (1.3.2-x86-mingw32) win32console (1.3.2-x86-mingw32)
xpath (1.0.0) xpath (1.0.0)
nokogiri (~> 1.3) nokogiri (~> 1.3)
zip-zip (0.3)
rubyzip (>= 1.0.0)
PLATFORMS PLATFORMS
ruby
x86-mingw32 x86-mingw32
DEPENDENCIES DEPENDENCIES
@ -240,11 +252,12 @@ DEPENDENCIES
coderay (~> 1.0.6) coderay (~> 1.0.6)
coffee-rails (~> 3.2.1) coffee-rails (~> 3.2.1)
fastercsv (~> 1.5.0) fastercsv (~> 1.5.0)
guard-minitest
guard-rails guard-rails
guard-spork guard-spork
guard-test (~> 1.0.0)
htmlentities htmlentities
i18n (~> 0.6.0) i18n (~> 0.6.0)
iconv
jquery-rails (~> 2.0.2) jquery-rails (~> 2.0.2)
kaminari kaminari
mocha (~> 0.13.3) mocha (~> 0.13.3)
@ -260,8 +273,12 @@ DEPENDENCIES
rich (= 1.4.6) rich (= 1.4.6)
rmagick (>= 2.0.0) rmagick (>= 2.0.0)
ruby-openid (~> 2.1.4) ruby-openid (~> 2.1.4)
ruby-prof
rubyzip
sass-rails (~> 3.2.3) sass-rails (~> 3.2.3)
seems_rateable! seems_rateable!
shoulda (> 3.3.2) shoulda (> 3.3.2)
spork-testunit
therubyracer therubyracer
uglifier (>= 1.0.3) uglifier (>= 1.0.3)
zip-zip

View File

@ -1,39 +1,11 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme # More info at https://github.com/guard/guard#readme
guard 'rails' do # guard 'rails' do
watch('Gemfile.lock') # watch('Gemfile.lock')
watch(%r{^(config|lib)/.*}) # watch(%r{^(config|lib)/.*})
end # end
#
guard 'spork', :test_unit => true, :test_unit_env => {'RAILS_ENV' => 'test'}, :wait => 60 do
guard :minitest, :drb => true, test_folders: 'test/unit', test_file_patterns: '*_test.rb' do
# with Minitest::Unit
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
watch(%r{^test/test_helper\.rb$}) { 'test' }
# with Minitest::Spec
# watch(%r{^spec/(.*)_spec\.rb$})
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
# watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
# Rails 4
# watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
# watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
# watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
# watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
# watch(%r{^test/.+_test\.rb$})
# watch(%r{^test/test_helper\.rb$}) { 'test' }
# Rails < 4
watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
end
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb') watch('config/application.rb')
watch('config/environment.rb') watch('config/environment.rb')
watch('config/environments/test.rb') watch('config/environments/test.rb')
@ -43,3 +15,25 @@ guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAIL
watch('test/test_helper.rb') { :test_unit } watch('test/test_helper.rb') { :test_unit }
watch(%r{features/support/}) { :cucumber } watch(%r{features/support/}) { :cucumber }
end end
guard :test, :drb => true, :all_after_pass => false, :all_on_start => false do
watch(%r{^test/.+_test\.rb$})
watch('test/test_helper.rb') { 'test' }
# Non-rails
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
# Rails 4
# watch(%r{^app/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
# watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' }
# watch(%r{^app/controllers/(.+)_controller\.rb}) { |m| "test/integration/#{m[1]}_test.rb" }
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
# watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" }
# Rails < 4
watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
watch(%r{^app/views/(.+)/.+\.erb$}) { |m| "test/functional/#{m[1]}_controller_test.rb" }
watch(%r{^app/views/.+$}) { 'test/integration' }
watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] }
end

Binary file not shown.

View File

@ -1,3 +1,55 @@
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
end
Spork.each_run do
# This code will be run each time you run your specs.
end
# --- Instructions ---
# Sort the contents of this file into a Spork.prefork and a Spork.each_run
# block.
#
# The Spork.prefork block is run only once when the spork server is started.
# You typically want to place most of your (slow) initializer code in here, in
# particular, require'ing any 3rd-party gems that you don't normally modify
# during development.
#
# The Spork.each_run block is run each time you run your specs. In case you
# need to load files that tend to change during development, require them here.
# With Rails, your application modules are loaded automatically, so sometimes
# this block can remain empty.
#
# Note: You can modify files loaded *from* the Spork.each_run block without
# restarting the spork server. However, this file itself will not be reloaded,
# so if you change any of the code inside the each_run block, you still need to
# restart the server. In general, if you have non-trivial code in this file,
# it's advisable to move it into a separate file so you can easily edit it
# without restarting spork. (For example, with RSpec, you could move
# non-trivial code into a file spec/support/my_helper.rb, making sure that the
# spec/support/* files are require'd from inside the each_run block.)
#
# Any code that is left outside the two blocks will be run during preforking
# *and* during each_run -- that's probably not what you want.
#
# These instructions should self-destruct in 10 seconds. If they don't, feel
# free to delete them.
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2013 Jean-Philippe Lang # Copyright (C) 2006-2013 Jean-Philippe Lang
# #