Created
August 1, 2024 03:03
-
-
Save Largo/9ca307435244d522fe1b1c3cf6c3f8c3 to your computer and use it in GitHub Desktop.
Check Value of globals that have changed between tests
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
config.before do | |
global_variables.each { |v| puts v } | |
$initial_globals = global_variables.map { |v| | |
$v = v | |
[v, eval(v.to_s)] | |
} - [[:$initial_globals, $initial_globals]] | |
rescue Exception => e | |
puts $v | |
puts "error in before block" | |
raise e | |
end | |
config.after do | |
current_globals = global_variables.map { |v| [v, eval(v.to_s)] } - [[:$initial_globals, $initial_globals]] | |
new_globals = current_globals - $initial_globals | |
removed_globals = $initial_globals - current_globals | |
unless new_globals.empty? && removed_globals.empty? | |
puts "New globals: #{new_globals.map(&:first)}" | |
puts "Removed globals: #{removed_globals.map(&:first)}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment