Metasploit::Framework::Spec::Constants cleaner

MSP-11130

Shared context will calls `Metasploit::Framework::Spec::Constants.clean
after each example.
bug/bundler_fix
Luke Imhoff 2014-10-29 11:31:17 -05:00
parent 0d4b22ce7a
commit 892aeaf727
No known key found for this signature in database
GPG Key ID: 5B1FB01FB33356F8
2 changed files with 14 additions and 0 deletions

View File

@ -1,3 +1,8 @@
# @note This should only temporarily be used in `spec/spec_helper.rb` when
# `Metasploit::Framework::Spec::Constants::Suite.configure!` detects a leak. Permanently having
# `Metasploit::Framework::Spec::Constants::Each.configure!` can lead to false positives when modules are purposely
# loaded in a `before(:all)` and cleaned up in a `after(:all)`.
#
# Fails example if it leaks module loading constants.
module Metasploit::Framework::Spec::Constants::Each
# Configures after(:each) callback for RSpe to fail example if leaked constants.
@ -16,6 +21,9 @@ module Metasploit::Framework::Spec::Constants::Each
lines << " #{child_name}"
end
lines << ''
lines << "Add `include_context 'Metasploit::Framework::Spec::Constants cleaner'` to clean up constants from #{example.metadata.full_description}"
message = lines.join("\n")
# clean so that leaks from one example aren't attributed to later examples

View File

@ -0,0 +1,6 @@
# Use in a context to clean up the constants that are created by the module loader.
shared_context 'Metasploit::Framework::Spec::Constants cleaner' do
after(:each) do
Metasploit::Framework::Spec::Constants.clean
end
end