Skip to content

Instantly share code, notes, and snippets.

@Largo
Created August 1, 2024 03:03
Show Gist options
  • Save Largo/9ca307435244d522fe1b1c3cf6c3f8c3 to your computer and use it in GitHub Desktop.
Save Largo/9ca307435244d522fe1b1c3cf6c3f8c3 to your computer and use it in GitHub Desktop.
Check Value of globals that have changed between tests
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