Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Raise an ArgumentError if an unknown state is used for comparison.

  • Loading branch information...
commit 0e0dd56f809a3ec0e3c3ec7d0be5123bcec3689c 1 parent 80eda5c
@svoop svoop authored
Showing with 4 additions and 0 deletions.
  1. +1 −0  lib/workflow.rb
  2. +3 −0  test/main_test.rb
View
1  lib/workflow.rb
@@ -90,6 +90,7 @@ def initialize(name, spec, meta = {})
def <=>(other_state)
states = spec.states.keys
+ raise ArgumentError, "state `#{other_state}' does not exist" unless other_state.in? states
if states.index(self.to_sym) < states.index(other_state.to_sym)
-1
elsif states.index(self.to_sym) > states.index(other_state.to_sym)
View
3  test/main_test.rb
@@ -248,6 +248,9 @@ def assert_state(title, expected_state, klass = Order)
o = assert_state 'some order', 'accepted'
assert o.current_state < :shipped
assert o.current_state > :submitted
+ assert_raise ArgumentError do
+ o.current_state > :unknown
+ end
end
test 'correct exception for event, that is not allowed in current state' do
Please sign in to comment.
Something went wrong with that request. Please try again.