Skip to content

Commit

Permalink
fast test !
Browse files Browse the repository at this point in the history
  • Loading branch information
barodeur committed Apr 24, 2013
1 parent fc8fc06 commit 3becd7f
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 36 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ group :development, :test do
gem 'rspec-rails'
gem 'mongoid-rspec'
gem 'sextant'
gem 'parallel_tests'
gem 'zeus-parallel_tests'
gem 'guard-rspec'
gem 'terminal-notifier-guard'

# debug
gem 'pry'
Expand Down
101 changes: 68 additions & 33 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,26 @@ GEM
activesupport (3.2.13)
i18n (= 0.6.1)
multi_json (~> 1.0)
ansi (1.4.3)
arel (3.0.2)
asset_sync (0.5.4)
activemodel
fog
bcrypt-ruby (3.0.1)
better_errors (0.7.2)
better_errors (0.8.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.1)
debug_inspector (>= 0.0.1)
bootstrap-addons-rails (0.1.2)
rails
bootstrap-datepicker-rails (1.0.0.1)
bootstrap-datepicker-rails (1.0.0.5)
railties (>= 3.0)
bootstrap-sass (2.3.1.0)
sass (~> 3.2)
builder (3.0.4)
cancan (1.6.9)
chosen-rails (0.9.12)
chosen-rails (0.9.13)
coffee-rails (>= 3.2)
railties (>= 3.0)
sass-rails (>= 3.2)
Expand All @@ -61,31 +62,32 @@ GEM
coffee-script (2.2.0)
coffee-script-source
execjs
coffee-script-source (1.6.1)
coffee-script-source (1.6.2)
database_cleaner (0.9.1)
debug_inspector (0.0.2)
devise (2.2.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.2.1)
diff-lcs (1.2.4)
doorkeeper (0.6.7)
railties (~> 3.1)
erubis (2.7.0)
excon (0.20.0)
excon (0.20.1)
execjs (1.4.0)
multi_json (~> 1.0)
factory_girl (4.2.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.2.1)
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
favicon_maker (0.2.0)
favicon_maker (0.2.1)
mini_magick (~> 3.5)
fog (1.10.0)
ffi (1.8.1)
fog (1.10.1)
builder
excon (~> 0.14)
excon (~> 0.20)
formatador (~> 0.2.0)
mime-types
multi_json (~> 1.0)
Expand All @@ -94,11 +96,20 @@ GEM
nokogiri (~> 1.5.0)
ruby-hmac
formatador (0.2.4)
haml (4.0.0)
guard (1.8.0)
formatador (>= 0.2.4)
listen (>= 1.0.0)
lumberjack (>= 1.0.2)
pry (>= 0.9.10)
thor (>= 0.14.6)
guard-rspec (2.5.4)
guard (>= 1.1)
rspec (~> 2.11)
haml (4.0.2)
tilt
hashr (0.0.22)
high_voltage (1.2.2)
hike (1.2.1)
hike (1.2.2)
i18n (0.6.1)
journey (1.0.4)
jquery-fileupload-rails (0.4.1)
Expand All @@ -108,44 +119,49 @@ GEM
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.7.7)
json_spec (1.1.0)
json_spec (1.1.1)
multi_json (~> 1.0)
rspec (~> 2.0)
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
listen (1.0.2)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
rb-kqueue (>= 0.2)
lumberjack (1.0.3)
mail (2.5.3)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
meta_request (0.2.2)
meta_request (0.2.3)
rack-contrib
railties
method_source (0.8.1)
mime-types (1.21)
mime-types (1.23)
mini_magick (3.5.0)
subexec (~> 0.2.1)
mongoid (3.1.2)
mongoid (3.1.3)
activemodel (~> 3.2)
moped (~> 1.4.2)
origin (~> 1.0)
tzinfo (~> 0.3.22)
mongoid-paperclip (0.0.8)
paperclip (>= 2.3.6)
mongoid-rspec (1.7.0)
mongoid-rspec (1.8.0)
mongoid (>= 3.0.1)
rake
rspec (>= 2.9)
mongoid_slug (3.0.0)
mongoid_slug (3.1.1)
mongoid (> 3.0)
stringex (~> 1.4)
moped (1.4.3)
multi_json (1.7.1)
moped (1.4.5)
multi_json (1.7.2)
net-scp (1.1.0)
net-ssh (>= 2.6.5)
net-ssh (2.6.6)
newrelic_rpm (3.5.8.72)
nokogiri (1.5.6)
net-ssh (2.6.7)
newrelic_rpm (3.6.0.83)
nokogiri (1.5.9)
origin (1.0.11)
orm_adapter (0.4.0)
paperclip (3.4.1)
Expand All @@ -154,10 +170,13 @@ GEM
activesupport (>= 3.0.0)
cocaine (~> 0.5.0)
mime-types
parallel (0.6.4)
parallel_tests (0.10.4)
parallel
placeholder (0.0.6)
polyglot (0.3.3)
posix-spawn (0.3.6)
pry (0.9.12)
pry (0.9.12.1)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
Expand All @@ -166,10 +185,10 @@ GEM
slop (~> 3.0)
puma (1.6.3)
rack (~> 1.2)
pygments.rb (0.4.2)
pygments.rb (0.5.0)
posix-spawn (~> 0.3.6)
yajl-ruby (~> 1.1.0)
rabl (0.8.0)
rabl (0.8.4)
activesupport (>= 2.3.14)
rack (1.4.5)
rack-cache (1.2)
Expand All @@ -195,7 +214,12 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.3)
rake (10.0.4)
rb-fsevent (0.9.3)
rb-inotify (0.9.0)
ffi (>= 0.5.0)
rb-kqueue (0.2.0)
ffi (>= 0.5.0)
rdoc (3.12.2)
json (~> 1.4)
redcarpet (2.2.2)
Expand All @@ -208,7 +232,7 @@ GEM
rspec-core (2.13.1)
rspec-expectations (2.13.0)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.0)
rspec-mocks (2.13.1)
rspec-rails (2.13.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
Expand All @@ -217,7 +241,7 @@ GEM
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
ruby-hmac (0.4.0)
sass (3.2.7)
sass (3.2.8)
sass-rails (3.2.6)
railties (~> 3.2.0)
sass (>= 3.1.10)
Expand All @@ -242,12 +266,14 @@ GEM
actionpack (~> 3.0)
activemodel (~> 3.0)
railties (~> 3.0)
subexec (0.2.2)
thor (0.17.0)
tilt (1.3.6)
tire (0.5.5)
subexec (0.2.3)
terminal-notifier-guard (1.5.3)
thor (0.18.1)
tilt (1.3.7)
tire (0.5.7)
activemodel (>= 3.0)
activesupport
ansi
hashr (~> 0.0.19)
multi_json (~> 1.3)
rake
Expand All @@ -256,12 +282,17 @@ GEM
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.37)
uglifier (1.3.0)
uglifier (2.0.1)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
warden (1.2.1)
rack (>= 1.0)
yajl-ruby (1.1.0)
zeus (0.13.3)
method_source (>= 0.6.7)
zeus-parallel_tests (0.2.1)
parallel_tests (~> 0.10.4)
zeus (~> 0.13.3)

PLATFORMS
ruby
Expand All @@ -282,6 +313,7 @@ DEPENDENCIES
factory_girl_rails
favicon_maker
fog
guard-rspec
haml
high_voltage
jquery-fileupload-rails
Expand All @@ -294,6 +326,7 @@ DEPENDENCIES
mongoid-rspec
mongoid_slug
newrelic_rpm
parallel_tests
placeholder
pry
pry-remote
Expand All @@ -309,5 +342,7 @@ DEPENDENCIES
sextant
simple_form
strong_parameters
terminal-notifier-guard
tire
uglifier (>= 1.0.3)
zeus-parallel_tests
23 changes: 23 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

guard 'rspec', all_on_start: false, all_after_pass: false, zeus: true, parallel: true, bundler: false do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }

# Rails example
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }

# Capybara features specs
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" }

# Turnip features and steps
watch(%r{^spec/acceptance/(.+)\.feature$})
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
end
10 changes: 10 additions & 0 deletions custom_plan.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'zeus/parallel_tests'

ENV['GUARD_NOTIFY'] = 'true'
ENV['GUARD_NOTIFICATIONS'] = "---\n- :name: :terminal_notifier\n :options: {}\n"

class CustomPlan < Zeus::ParallelTests::Rails
# Your custom methods go here
end

Zeus.plan = CustomPlan.new
1 change: 0 additions & 1 deletion spec/api/v1/api_v1_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'spec_helper'
require 'rack/test'

describe Api::V1 do
let(:application) { FactoryGirl.create :oauth_application }
Expand Down
14 changes: 12 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'rack/test'

Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
Expand All @@ -14,5 +13,16 @@
config.before :each do
DatabaseCleaner.clean
end
end

config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run focus: true
config.run_all_when_everything_filtered = true

config.before(:all) do
DeferredGarbageCollection.start
end

config.after(:all) do
DeferredGarbageCollection.reconsider
end
end
19 changes: 19 additions & 0 deletions spec/support/deferred_garbage_collection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class DeferredGarbageCollection

DEFERRED_GC_THRESHOLD = (ENV['DEFER_GC'] || 15.0).to_f

@@last_gc_run = Time.now

def self.start
GC.disable if DEFERRED_GC_THRESHOLD > 0
end

def self.reconsider
if DEFERRED_GC_THRESHOLD > 0 && Time.now - @@last_gc_run >= DEFERRED_GC_THRESHOLD
GC.enable
GC.start
GC.disable
@@last_gc_run = Time.now
end
end
end
26 changes: 26 additions & 0 deletions zeus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"command": "ruby -rubygems -r./custom_plan -eZeus.go",

"plan": {
"boot": {
"default_bundle": {
"development_environment": {
"prerake": {"rake": []},
"runner": ["r"],
"console": ["c"],
"server": ["s"],
"generate": ["g"],
"destroy": ["d"],
"dbconsole": [],
"parallel_rspec": []
},
"test_environment": {
"test_helper": {
"test": ["rspec", "testrb"],
"parallel_rspec_worker": []
}
}
}
}
}
}

0 comments on commit 3becd7f

Please sign in to comment.