mgonto/factory_pal — pull request #12 by NeQuissimus (2013-01-24 19:24:51+00:00)
Title: Helpers

Automatically register all subclasses of a sealed trait.
This greatly simplifies using FactoryPal with multiple objects.

Simply create a **sealed trait** that extends PalTrait and have all your
test objects inherit from PalObject as well as this new trait.
Then include this trait in your test specification and call register()
and everything else will be taken care of. No need to register each individual
test object.

Example:

```
sealed trait MyTestObjects extends PalTrait
class MyTestObject1 extends PalObject[MyObject1] with MyTestObjects {
def register() = {
FactoryPal.register[MyObject1]() { o =>
o.id.mapsTo("ID1") and
o.name.mapsTo("Name1")
}
}
}
class MyTestObject2 extends PalObject[MyObject2] with MyTestObjects {
def register() = {
FactoryPal.register[MyObject2]() { o =>
o.id.mapsTo("ID2") and
o.value.mapsTo("Value2")
}
}
}
class ScannerSpec extends FunSpec with ShouldMatchers with SpecHelper {
register[MyTestObjects]()
// Your tests here
}
```