edge-state-machine 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -1
- data/edge-state-machine.gemspec +1 -1
- data/lib/edge-state-machine/version.rb +1 -1
- data/spec/active_record/active_record_spec.rb +4 -4
- data/spec/event_spec.rb +1 -1
- data/spec/mongo_mapper/mongo_mapper_spec.rb +4 -4
- data/spec/mongoid/double_machine_spec.rb +3 -1
- data/spec/mongoid/mongoid.yml +6 -0
- data/spec/mongoid/mongoid_helper.rb +2 -4
- data/spec/mongoid/mongoid_spec.rb +10 -6
- metadata +92 -20
data/.travis.yml
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
rvm: 1.9.
|
1
|
+
rvm: 1.9.3
|
2
|
+
services: mongodb
|
data/edge-state-machine.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
|
22
22
|
# specify any dependencies here; for example:
|
23
|
-
s.add_development_dependency 'rspec'
|
23
|
+
s.add_development_dependency 'rspec'
|
24
24
|
s.add_development_dependency 'rake'
|
25
25
|
s.add_development_dependency 'mongoid'
|
26
26
|
s.add_development_dependency 'mongo_mapper'
|
@@ -49,7 +49,7 @@ describe 'active record state machine' do
|
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should raise error on transition to an invalid state' do
|
52
|
-
expect { light.yellow_on }.
|
52
|
+
expect { light.yellow_on }.to raise_error EdgeStateMachine::NoTransitionFound
|
53
53
|
light.current_state.should == :off
|
54
54
|
end
|
55
55
|
|
@@ -72,14 +72,14 @@ describe 'active record state machine' do
|
|
72
72
|
|
73
73
|
it 'should raise exception when model validation fails on transition' do
|
74
74
|
validating_light = ValidatingTrafficLight.create!
|
75
|
-
expect {validating_light.reset!}.
|
75
|
+
expect {validating_light.reset!}.to raise_error ActiveRecord::RecordInvalid
|
76
76
|
validating_light.red?.should == false
|
77
77
|
validating_light.off?.should == true
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'should state query method used in a validation condition' do
|
81
81
|
validating_light = ConditionalValidatingTrafficLight.create!
|
82
|
-
#expect {validating_light.reset!}.
|
82
|
+
#expect {validating_light.reset!}.to raise_error ActiveRecord::RecordInvalid
|
83
83
|
validating_light.off?.should == true
|
84
84
|
validating_light.red?.should == false
|
85
85
|
end
|
@@ -135,7 +135,7 @@ describe 'active record state machine' do
|
|
135
135
|
# control case, no timestamp has been set so we should expect default behaviour
|
136
136
|
it 'should not raise any exceptions when moving to placed' do
|
137
137
|
@order = create_order
|
138
|
-
expect { @order.place! }.
|
138
|
+
expect { @order.place! }.to_not raise_error
|
139
139
|
@order.state.should == 'placed'
|
140
140
|
end
|
141
141
|
end
|
data/spec/event_spec.rb
CHANGED
@@ -62,7 +62,7 @@ describe EdgeStateMachine::Event do
|
|
62
62
|
event = EdgeStateMachine::Event.new(:event, @machine)
|
63
63
|
obj = mock
|
64
64
|
obj.stub!(:current_state).and_return(:open)
|
65
|
-
expect {event.fire(obj)}.
|
65
|
+
expect {event.fire(obj)}.to raise_error EdgeStateMachine::NoTransitionFound
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -47,7 +47,7 @@ describe 'mongo_mapper state machine' do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should raise error on transition to an invalid state' do
|
50
|
-
expect { light.yellow_on }.
|
50
|
+
expect { light.yellow_on }.to raise_error EdgeStateMachine::NoTransitionFound
|
51
51
|
light.current_state.should == :off
|
52
52
|
end
|
53
53
|
|
@@ -70,12 +70,12 @@ describe 'mongo_mapper state machine' do
|
|
70
70
|
|
71
71
|
it 'should raise exception when model validation fails on transition' do
|
72
72
|
validating_light = MongoMapperValidatingTrafficLight.create!
|
73
|
-
expect {validating_light.reset!}.
|
73
|
+
expect {validating_light.reset!}.to raise_error MongoMapper::DocumentNotValid
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should state query method used in a validation condition' do
|
77
77
|
validating_light = MongoMapperConditionalValidatingTrafficLight.create!
|
78
|
-
#expect {validating_light.reset!}.
|
78
|
+
#expect {validating_light.reset!}.to raise_error Mongoid::RecordInvalid
|
79
79
|
validating_light.off?.should == true
|
80
80
|
end
|
81
81
|
|
@@ -127,7 +127,7 @@ describe 'mongo_mapper state machine' do
|
|
127
127
|
# control case, no timestamp has been set so we should expect default behaviour
|
128
128
|
it 'should not raise any exceptions when moving to placed' do
|
129
129
|
@order = create_order
|
130
|
-
expect { @order.place! }.
|
130
|
+
expect { @order.place! }.to_not raise_error
|
131
131
|
@order.state.should == 'placed'
|
132
132
|
end
|
133
133
|
end
|
@@ -3,7 +3,9 @@ require 'mongoid/mongoid_helper'
|
|
3
3
|
describe DoubleMachineMongoid do
|
4
4
|
|
5
5
|
before do
|
6
|
-
|
6
|
+
session = Moped::Session.new([ 'localhost:27017' ])
|
7
|
+
session.use 'edge-state-machine-test'
|
8
|
+
session.drop
|
7
9
|
end
|
8
10
|
|
9
11
|
let :double_machine do
|
@@ -9,7 +9,5 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
9
9
|
|
10
10
|
require 'mongoid/edge-state-machine'
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
config.allow_dynamic_fields = false
|
15
|
-
end
|
12
|
+
ENV['RACK_ENV'] = 'test'
|
13
|
+
Mongoid.load!(File.dirname(__FILE__) + '/mongoid.yml')
|
@@ -4,7 +4,9 @@ describe 'mongoid state machine' do
|
|
4
4
|
|
5
5
|
context 'existing mongo document' do
|
6
6
|
before do
|
7
|
-
|
7
|
+
session = Moped::Session.new([ 'localhost:27017' ])
|
8
|
+
session.use 'edge-state-machine-test'
|
9
|
+
session.drop
|
8
10
|
end
|
9
11
|
|
10
12
|
let :light do
|
@@ -47,7 +49,7 @@ describe 'mongoid state machine' do
|
|
47
49
|
end
|
48
50
|
|
49
51
|
it 'should raise error on transition to an invalid state' do
|
50
|
-
expect { light.yellow_on }.
|
52
|
+
expect { light.yellow_on }.to raise_error EdgeStateMachine::NoTransitionFound
|
51
53
|
light.current_state.should == :off
|
52
54
|
end
|
53
55
|
|
@@ -70,12 +72,12 @@ describe 'mongoid state machine' do
|
|
70
72
|
|
71
73
|
it 'should raise exception when model validation fails on transition' do
|
72
74
|
validating_light = MongoValidatingTrafficLight.create!
|
73
|
-
expect {validating_light.reset!}.
|
75
|
+
expect {validating_light.reset!}.to raise_error Mongoid::Errors::Validations
|
74
76
|
end
|
75
77
|
|
76
78
|
it 'should state query method used in a validation condition' do
|
77
79
|
validating_light = MongoConditionalValidatingTrafficLight.create!
|
78
|
-
#expect {validating_light.reset!}.
|
80
|
+
#expect {validating_light.reset!}.to raise_error Mongoid::RecordInvalid
|
79
81
|
validating_light.off?.should == true
|
80
82
|
end
|
81
83
|
|
@@ -118,7 +120,9 @@ describe 'mongoid state machine' do
|
|
118
120
|
|
119
121
|
context 'timestamp' do
|
120
122
|
before do
|
121
|
-
|
123
|
+
session = Moped::Session.new([ 'localhost:27017' ])
|
124
|
+
session.use 'edge-state-machine-test'
|
125
|
+
session.drop
|
122
126
|
end
|
123
127
|
|
124
128
|
def create_order(state = nil)
|
@@ -128,7 +132,7 @@ describe 'mongoid state machine' do
|
|
128
132
|
# control case, no timestamp has been set so we should expect default behaviour
|
129
133
|
it 'should not raise any exceptions when moving to placed' do
|
130
134
|
@order = create_order
|
131
|
-
expect { @order.place! }.
|
135
|
+
expect { @order.place! }.to_not raise_error
|
132
136
|
@order.state.should == 'placed'
|
133
137
|
end
|
134
138
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edge-state-machine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rake
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: mongoid
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: mongo_mapper
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: bson_ext
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ! '>='
|
@@ -65,10 +85,15 @@ dependencies:
|
|
65
85
|
version: '0'
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: sqlite3-ruby
|
71
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
72
97
|
none: false
|
73
98
|
requirements:
|
74
99
|
- - ! '>='
|
@@ -76,10 +101,15 @@ dependencies:
|
|
76
101
|
version: '0'
|
77
102
|
type: :development
|
78
103
|
prerelease: false
|
79
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: activerecord
|
82
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
83
113
|
none: false
|
84
114
|
requirements:
|
85
115
|
- - ! '>='
|
@@ -87,7 +117,12 @@ dependencies:
|
|
87
117
|
version: '0'
|
88
118
|
type: :development
|
89
119
|
prerelease: false
|
90
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
91
126
|
description: Edge State Machine is a complete state machine solution. It offers support
|
92
127
|
for ActiveRecord, Mongoid and MongoMapper for persistence.
|
93
128
|
email:
|
@@ -131,6 +166,7 @@ files:
|
|
131
166
|
- spec/mongo_mapper/samples/order.rb
|
132
167
|
- spec/mongo_mapper/samples/traffic_light.rb
|
133
168
|
- spec/mongoid/double_machine_spec.rb
|
169
|
+
- spec/mongoid/mongoid.yml
|
134
170
|
- spec/mongoid/mongoid_helper.rb
|
135
171
|
- spec/mongoid/mongoid_spec.rb
|
136
172
|
- spec/mongoid/samples/double_machine.rb
|
@@ -168,8 +204,44 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
204
|
version: '0'
|
169
205
|
requirements: []
|
170
206
|
rubyforge_project: edge-state-machine
|
171
|
-
rubygems_version: 1.8.
|
207
|
+
rubygems_version: 1.8.24
|
172
208
|
signing_key:
|
173
209
|
specification_version: 3
|
174
210
|
summary: Edge State Machine
|
175
|
-
test_files:
|
211
|
+
test_files:
|
212
|
+
- spec/active_record/active_record_helper.rb
|
213
|
+
- spec/active_record/active_record_spec.rb
|
214
|
+
- spec/active_record/double_machine_spec.rb
|
215
|
+
- spec/active_record/migrations/create_double_machine.rb
|
216
|
+
- spec/active_record/migrations/create_orders.rb
|
217
|
+
- spec/active_record/migrations/create_traffic_lights.rb
|
218
|
+
- spec/active_record/samples/double_machine.rb
|
219
|
+
- spec/active_record/samples/order.rb
|
220
|
+
- spec/active_record/samples/traffic_light.rb
|
221
|
+
- spec/event_spec.rb
|
222
|
+
- spec/machine_spec.rb
|
223
|
+
- spec/mongo_mapper/double_machine_spec.rb
|
224
|
+
- spec/mongo_mapper/mongo_mapper_helper.rb
|
225
|
+
- spec/mongo_mapper/mongo_mapper_spec.rb
|
226
|
+
- spec/mongo_mapper/samples/double_machine.rb
|
227
|
+
- spec/mongo_mapper/samples/order.rb
|
228
|
+
- spec/mongo_mapper/samples/traffic_light.rb
|
229
|
+
- spec/mongoid/double_machine_spec.rb
|
230
|
+
- spec/mongoid/mongoid.yml
|
231
|
+
- spec/mongoid/mongoid_helper.rb
|
232
|
+
- spec/mongoid/mongoid_spec.rb
|
233
|
+
- spec/mongoid/samples/double_machine.rb
|
234
|
+
- spec/mongoid/samples/order.rb
|
235
|
+
- spec/mongoid/samples/traffic_light.rb
|
236
|
+
- spec/non_persistent/double_machine_spec.rb
|
237
|
+
- spec/non_persistent/non_persistent_helper.rb
|
238
|
+
- spec/non_persistent/non_persistent_spec.rb
|
239
|
+
- spec/non_persistent/on_off_switch_spec.rb
|
240
|
+
- spec/non_persistent/samples/dice.rb
|
241
|
+
- spec/non_persistent/samples/double_machine.rb
|
242
|
+
- spec/non_persistent/samples/microwave.rb
|
243
|
+
- spec/non_persistent/samples/on_off_switch.rb
|
244
|
+
- spec/non_persistent/samples/user.rb
|
245
|
+
- spec/spec_helper.rb
|
246
|
+
- spec/state_spec.rb
|
247
|
+
- spec/transition_spec.rb
|