Skip to content

Instantly share code, notes, and snippets.

@spikeheap
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save spikeheap/2e3f371615deb276f46e to your computer and use it in GitHub Desktop.

Select an option

Save spikeheap/2e3f371615deb276f46e to your computer and use it in GitHub Desktop.
Simple introspection to dig into model inequality in Spock tests
def expected
def actual
def propertiesToCompare = expected.class.declaredFields.findAll { !(it.name =~ /^__/ || it.name =~ /^\$/ || it.name == "metaClass") }
// For each property prints [equality] : [property name] -> [expected value] -|- [actual value]
propertiesToCompare.each { property ->
println "${expected[property.name] == actual[property.name]} : ${property} -> ${expected[property.name]} -|exp: ${actual[property.name]} "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment