Skip to content

Instantly share code, notes, and snippets.

@cassiomarques
Created February 23, 2011 19:16
Show Gist options
  • Save cassiomarques/840969 to your computer and use it in GitHub Desktop.
Save cassiomarques/840969 to your computer and use it in GitHub Desktop.
# Using Rspec 2.5.0 + Spork
#
# Before the hack:
# 2131/2131: 100% |==========================================| Time: 00:02:26
#
# After the hack:
# 2131/2131: 100% |==========================================| Time: 00:02:09
# spec/spec_helper.rb (simplified...)
# Adapted from http://37signals.com/svn/posts/2742-the-road-to-faster-tests
module FasterTests
def scrub_instance_variables
reserved_ivars = %w(@loaded_fixtures @test_passed @fixture_cache @method_name @_assertion_wrapped @_result)
(instance_variables - reserved_ivars).each do |ivar|
instance_variable_set(ivar, nil)
end
end
end
RSpec.configure do |config|
config.include FasterTests
config.before(:all) { scrub_instance_variables }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment