Created
January 21, 2011 18:01
-
-
Save cheeyeo/790094 to your computer and use it in GitHub Desktop.
Rspec optmization techniques borrowed from 37Signals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# method for clearing out instance variables from code blocks | |
# usage: | |
Spec::Runner.configure do |config| | |
..... | |
config.after(:each) do | |
scrub_instance_variables | |
end | |
end | |
....... | |
@@reserved_ivars = %w(@selected @_backtrace @_proxy @data_tem @_implementation @request @loaded_fixtures @controller @method_name @fixture_cache @_result @deliveries @response @test_passed @_assertion_wrapped) | |
# instance_variables is an actual method in the rspec source code | |
def scrub_instance_variables | |
(instance_variables - @@reserved_ivars).each do |ivar| | |
instance_variable_set(ivar, nil) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment