end_state 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f58a215a5954fd5bb0cc3241fbfd788a42aa01f7
4
- data.tar.gz: 1649c7a9404589b4c3fe167db290015849ebc085
3
+ metadata.gz: 5b3e18cd51ed06158bb7ed2b08c54bc8bfc9e46d
4
+ data.tar.gz: 160cda6e0637500fc5335ef0249d2803cf1991cb
5
5
  SHA512:
6
- metadata.gz: 963412f0c3548c8c1e2667aafb93ad956d094efca44095ae143fcedb0f6a7d211f8a70513f35ae100c98d49e130dc6b8233e1bd422ef6118b9db4715feca8d0a
7
- data.tar.gz: 1fb665f112c2a43cb582a3e145530169a37ea09eaf495f62676130c36c2453af88fa8356d2d9b71b021d8374be46e419eb0543c87c79e237e991dacc01487f9d
6
+ metadata.gz: 0c44b0fbfaedf0bf7061d8204a93f25b0b08166a7e1e057a969d685a34130fb95939706d5e87d1af4a3f98fb33300b1a728c4378bb529115834bef9be6664fa5
7
+ data.tar.gz: c107d7cfd7a474d528b4c0295e6e806de98477d6860fd9e82c91e6a324724fc0623701472799b7383184bf2816a6e95a3f0d8b9965ae63f6a7470dccc501b570
@@ -85,7 +85,7 @@ module EndState
85
85
  end
86
86
 
87
87
  def __sm_invalid_event(event, mode)
88
- fail InvalidTransition, "Transition by event: #{event} is invalid." if mode == :hard
88
+ Kernel.fail InvalidTransition, "Transition by event: #{event} is invalid." if mode == :hard
89
89
  :__invalid_event__
90
90
  end
91
91
 
@@ -103,10 +103,10 @@ module EndState
103
103
 
104
104
  def __sm_block_transistion(state, mode)
105
105
  if self.class.end_states.include? state
106
- fail InvalidTransition, "The transition: #{object.state} => #{state} is invalid." if mode == :hard
106
+ Kernel.fail InvalidTransition, "The transition: #{object.state} => #{state} is invalid." if mode == :hard
107
107
  return false
108
108
  end
109
- fail UnknownState, "The state: #{state} is unknown."
109
+ Kernel.fail UnknownState, "The state: #{state} is unknown."
110
110
  end
111
111
 
112
112
  def __sm_reset_messages
@@ -71,7 +71,7 @@ module EndState
71
71
 
72
72
  def prevent_event_conflicts(start_state, event)
73
73
  return unless transition_configurations.event_conflicts?(start_state, event)
74
- fail EventConflict, "Attempting to define event '#{event}' on state '#{start_state}', but it is already defined. (Check duplicates and use of 'any_state')"
74
+ Kernel.fail EventConflict, "Attempting to define event '#{event}' on state '#{start_state}', but it is already defined. (Check duplicates and use of 'any_state')"
75
75
  end
76
76
  end
77
77
  end
@@ -31,7 +31,7 @@ module EndState
31
31
 
32
32
  def failed(error, message)
33
33
  return false unless mode == :hard
34
- fail error, "The transition to #{state} was #{message}: #{object.failure_messages.join(', ')}"
34
+ Kernel.fail error, "The transition to #{state} was #{message}: #{object.failure_messages.join(', ')}"
35
35
  end
36
36
 
37
37
  def guard_failed
@@ -43,7 +43,7 @@ module EndState
43
43
  end
44
44
 
45
45
  def params_not_provided(params_list)
46
- fail MissingParams, "Missing params: #{params_list.join(',')}"
46
+ Kernel.fail MissingParams, "Missing params: #{params_list.join(',')}"
47
47
  end
48
48
 
49
49
  def conclude(params={})
@@ -1,3 +1,3 @@
1
1
  module EndState
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -228,6 +228,27 @@ module EndState
228
228
  expect(machine.state).to eq :end
229
229
  end
230
230
  end
231
+
232
+ context 'when a transition is named fail' do
233
+ let(:object) { OpenStruct.new(state: :a) }
234
+ before do
235
+ StateMachine.transition a: :c, as: :fail
236
+ StateMachine.transition c: :d, as: :other
237
+ end
238
+
239
+ it 'raises the proper error for invalid transitions' do
240
+ expect { machine.transition! :d }.to raise_error(InvalidTransition)
241
+ end
242
+
243
+ it 'raises the proper error for transitions to unknown states' do
244
+ expect { machine.transition(:no_state) }.to raise_error(UnknownState)
245
+ end
246
+
247
+ it 'transitions properly when directly calling fail' do
248
+ machine.fail!
249
+ expect(machine.state).to eq :c
250
+ end
251
+ end
231
252
  end
232
253
 
233
254
  describe '#can_transition?' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: end_state
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - alexpeachey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler