Created
March 21, 2013 23:27
-
-
Save robfletcher/5217772 to your computer and use it in GitHub Desktop.
This file contains 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
package spock.extensions.state | |
class StateMachine<E extends Enum> { | |
private final String name | |
private E currentState | |
StateMachine(String name, E initialState) { | |
this.name = name | |
currentState = initialState | |
} | |
void becomes(E newState) { | |
currentState = newState | |
} | |
void is(E expectedState) { | |
assert currentState == expectedState, "$name state should be $expectedState but is $currentState" | |
} | |
void isNot(E expectedState) { | |
assert currentState != expectedState, "$name state should not be $expectedState but it is" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment