Metasploit::Framework::Spec::Constants cleaner
MSP-11130 Shared context will calls `Metasploit::Framework::Spec::Constants.clean after each example.bug/bundler_fix
parent
0d4b22ce7a
commit
892aeaf727
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue