Skip to content

Instantly share code, notes, and snippets.

@jeremywrowe
Last active December 15, 2015 20:41
Show Gist options
  • Save jeremywrowe/5320537 to your computer and use it in GitHub Desktop.
Save jeremywrowe/5320537 to your computer and use it in GitHub Desktop.
Show leaked instance variables in cucumber. A terrible hack but sometimes that is what ya need to do :)
$cucumber_instance_variables = []
Before do
$cucumber_instance_variables = instance_variables
end
After do
test_variables = instance_variables - $cucumber_instance_variables
message = "[WARN] the following test variables could be leaking #{leaked_variables.join(', ')}"
puts message if test_variables.any? and ENV['SHOW_TEST_VARS']
test_variables.each {|v| instance_variable_set v, nil }
$cucumber_instance_variables = []
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment