Sets the specified object as the implicit target of the top-level conditions and/or
interactions contained in the specified code block, thereby avoiding the need to repeat
the same expression multiple times. Implicit conditions are supported. (In other words,
assert keyword may be omitted.) If the target is
SpockAssertionError is thrown.
with block can be used anywhere in a spec, including nested positions
and helper methods.
def fred = new Person(name: "Fred", age: 42)
def spaceship = new Spaceship(pilot: fred)
name == "Fred" // shorthand for: spaceship.pilot.name == "Fred"
age == 42
def service = Mock(Service) // has start(), stop(), and doWork() methods
def app = new Application(service) // controls the lifecycle of the service
1 * start() // shorthand for: 1 * service.start()
1 * doWork()
1 * stop()