state_machines 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/README.md +25 -0
- data/Rakefile +10 -1
- data/lib/state_machines/branch.rb +0 -4
- data/lib/state_machines/core.rb +23 -5
- data/lib/state_machines/error.rb +81 -2
- data/lib/state_machines/event.rb +2 -20
- data/lib/state_machines/event_collection.rb +25 -27
- data/lib/state_machines/extensions.rb +34 -34
- data/lib/state_machines/integrations.rb +98 -90
- data/lib/state_machines/integrations/base.rb +11 -60
- data/lib/state_machines/matcher.rb +0 -2
- data/lib/state_machines/node_collection.rb +0 -2
- data/lib/state_machines/path_collection.rb +0 -2
- data/lib/state_machines/state.rb +0 -3
- data/lib/state_machines/state_collection.rb +17 -19
- data/lib/state_machines/state_context.rb +1 -6
- data/lib/state_machines/transition.rb +0 -56
- data/lib/state_machines/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/state_machines/assertions_spec.rb +31 -0
- data/spec/state_machines/branch_spec.rb +827 -0
- data/spec/state_machines/callbacks_spec.rb +706 -0
- data/spec/state_machines/errors_spec.rb +1 -0
- data/spec/state_machines/event_collection_spec.rb +401 -0
- data/spec/state_machines/event_spec.rb +1140 -0
- data/spec/{helpers → state_machines}/helper_spec.rb +0 -0
- data/spec/state_machines/integration_base_spec.rb +12 -0
- data/spec/state_machines/integration_spec.rb +132 -0
- data/spec/state_machines/invalid_event_spec.rb +19 -0
- data/spec/state_machines/invalid_parallel_transition_spec.rb +18 -0
- data/spec/state_machines/invalid_transition_spec.rb +114 -0
- data/spec/state_machines/machine_collection_spec.rb +606 -0
- data/spec/{machine_spec.rb → state_machines/machine_spec.rb} +11 -2
- data/spec/{matcher_helpers_spec.rb → state_machines/matcher_helpers_spec.rb} +0 -0
- data/spec/{matcher_spec.rb → state_machines/matcher_spec.rb} +0 -0
- data/spec/{node_collection_spec.rb → state_machines/node_collection_spec.rb} +0 -0
- data/spec/{path_collection_spec.rb → state_machines/path_collection_spec.rb} +0 -0
- data/spec/{path_spec.rb → state_machines/path_spec.rb} +0 -0
- data/spec/{state_collection_spec.rb → state_machines/state_collection_spec.rb} +0 -0
- data/spec/{state_context_spec.rb → state_machines/state_context_spec.rb} +0 -0
- data/spec/{state_machine_spec.rb → state_machines/state_machine_spec.rb} +0 -0
- data/spec/{state_spec.rb → state_machines/state_spec.rb} +0 -0
- data/spec/{transition_collection_spec.rb → state_machines/transition_collection_spec.rb} +0 -0
- data/spec/{transition_spec.rb → state_machines/transition_spec.rb} +0 -0
- data/spec/support/migration_helpers.rb +9 -0
- data/state_machines.gemspec +3 -1
- metadata +68 -45
- data/lib/state_machines/yard.rb +0 -8
- data/spec/errors/default_spec.rb +0 -14
- data/spec/errors/with_message_spec.rb +0 -39
@@ -521,6 +521,7 @@ describe StateMachines::Machine do
|
|
521
521
|
|
522
522
|
after(:all) do
|
523
523
|
StateMachines::Integrations.send(:remove_const, 'Custom')
|
524
|
+
StateMachines::Integrations.send(:reset)
|
524
525
|
end
|
525
526
|
end
|
526
527
|
|
@@ -612,6 +613,7 @@ describe StateMachines::Machine do
|
|
612
613
|
after(:each) do
|
613
614
|
self.class.send(:remove_const, 'Vehicle')
|
614
615
|
StateMachines::Integrations.send(:remove_const, 'Custom')
|
616
|
+
StateMachines::Integrations.send(:reset)
|
615
617
|
end
|
616
618
|
end
|
617
619
|
|
@@ -681,6 +683,7 @@ describe StateMachines::Machine do
|
|
681
683
|
|
682
684
|
after(:each) do
|
683
685
|
StateMachines::Integrations.send(:remove_const, 'Custom')
|
686
|
+
StateMachines::Integrations.send(:reset)
|
684
687
|
end
|
685
688
|
end
|
686
689
|
|
@@ -942,6 +945,7 @@ describe StateMachines::Machine do
|
|
942
945
|
|
943
946
|
after(:each) do
|
944
947
|
StateMachines::Integrations.send(:remove_const, 'Custom')
|
948
|
+
StateMachines::Integrations.send(:reset)
|
945
949
|
end
|
946
950
|
end
|
947
951
|
|
@@ -986,6 +990,7 @@ describe StateMachines::Machine do
|
|
986
990
|
|
987
991
|
after(:each) do
|
988
992
|
StateMachines::Integrations.send(:remove_const, 'Custom')
|
993
|
+
StateMachines::Integrations.send(:reset)
|
989
994
|
end
|
990
995
|
end
|
991
996
|
|
@@ -1625,6 +1630,7 @@ describe StateMachines::Machine do
|
|
1625
1630
|
after(:each) do
|
1626
1631
|
$stderr = @original_stderr
|
1627
1632
|
StateMachines::Integrations.send(:remove_const, 'Custom')
|
1633
|
+
StateMachines::Integrations.send(:reset)
|
1628
1634
|
end
|
1629
1635
|
|
1630
1636
|
|
@@ -1879,6 +1885,7 @@ describe StateMachines::Machine do
|
|
1879
1885
|
after(:each) do
|
1880
1886
|
$stderr = @original_stderr
|
1881
1887
|
StateMachines::Integrations.send(:remove_const, 'Custom')
|
1888
|
+
StateMachines::Integrations.send(:reset)
|
1882
1889
|
end
|
1883
1890
|
end
|
1884
1891
|
|
@@ -2343,11 +2350,11 @@ describe StateMachines::Machine do
|
|
2343
2350
|
let!(:same_event) { machine.event(:ignite) }
|
2344
2351
|
|
2345
2352
|
it 'should_not_create_new_event ' do
|
2346
|
-
|
2353
|
+
expect(event).to equal(same_event)
|
2347
2354
|
end
|
2348
2355
|
|
2349
2356
|
it 'should_allow_accessing_event_without_block ' do
|
2350
|
-
|
2357
|
+
expect(machine.event(:ignite)).to eq(event)
|
2351
2358
|
end
|
2352
2359
|
end
|
2353
2360
|
|
@@ -3028,6 +3035,7 @@ describe StateMachines::Machine do
|
|
3028
3035
|
|
3029
3036
|
after(:each) do
|
3030
3037
|
StateMachines::Integrations.send(:remove_const, 'Custom')
|
3038
|
+
StateMachines::Integrations.send(:reset)
|
3031
3039
|
end
|
3032
3040
|
end
|
3033
3041
|
|
@@ -3149,6 +3157,7 @@ describe StateMachines::Machine do
|
|
3149
3157
|
|
3150
3158
|
after(:each) do
|
3151
3159
|
StateMachines::Integrations.send(:remove_const, 'Custom')
|
3160
|
+
StateMachines::Integrations.send(:reset)
|
3152
3161
|
end
|
3153
3162
|
end
|
3154
3163
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/state_machines.gemspec
CHANGED
@@ -10,9 +10,10 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['terminale@gmail.com']
|
11
11
|
spec.summary = %q(State machines for attributes)
|
12
12
|
spec.description = %q(Adds support for creating state machines for attributes on any Ruby class)
|
13
|
-
spec.homepage = ''
|
13
|
+
spec.homepage = 'https://github.com/seuros/state_machines'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
|
+
spec.required_ruby_version = '>= 1.9.3'
|
16
17
|
spec.files = `git ls-files -z`.split("\x0")
|
17
18
|
spec.test_files = spec.files.grep(/^spec\//)
|
18
19
|
spec.require_paths = ['lib']
|
@@ -20,4 +21,5 @@ Gem::Specification.new do |spec|
|
|
20
21
|
spec.add_development_dependency 'bundler'
|
21
22
|
spec.add_development_dependency 'rake'
|
22
23
|
spec.add_development_dependency 'rspec' , '3.0.0.beta2'
|
24
|
+
spec.add_development_dependency 'rspec-its'
|
23
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: state_machines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -53,6 +53,20 @@ dependencies:
|
|
53
53
|
- - '='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: 3.0.0.beta2
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec-its
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
56
70
|
description: Adds support for creating state machines for attributes on any Ruby class
|
57
71
|
email:
|
58
72
|
- terminale@gmail.com
|
@@ -61,16 +75,6 @@ extensions: []
|
|
61
75
|
extra_rdoc_files: []
|
62
76
|
files:
|
63
77
|
- ".gitignore"
|
64
|
-
- ".idea/.name"
|
65
|
-
- ".idea/.rakeTasks"
|
66
|
-
- ".idea/cssxfire.xml"
|
67
|
-
- ".idea/encodings.xml"
|
68
|
-
- ".idea/misc.xml"
|
69
|
-
- ".idea/modules.xml"
|
70
|
-
- ".idea/scopes/scope_settings.xml"
|
71
|
-
- ".idea/state_machine2.iml"
|
72
|
-
- ".idea/vcs.xml"
|
73
|
-
- ".idea/workspace.xml"
|
74
78
|
- ".rspec"
|
75
79
|
- ".travis.yml"
|
76
80
|
- Gemfile
|
@@ -106,38 +110,47 @@ files:
|
|
106
110
|
- lib/state_machines/transition.rb
|
107
111
|
- lib/state_machines/transition_collection.rb
|
108
112
|
- lib/state_machines/version.rb
|
109
|
-
- lib/state_machines/yard.rb
|
110
|
-
- spec/errors/default_spec.rb
|
111
|
-
- spec/errors/with_message_spec.rb
|
112
|
-
- spec/helpers/helper_spec.rb
|
113
113
|
- spec/internal/app/models/auto_shop.rb
|
114
114
|
- spec/internal/app/models/car.rb
|
115
115
|
- spec/internal/app/models/model_base.rb
|
116
116
|
- spec/internal/app/models/motorcycle.rb
|
117
117
|
- spec/internal/app/models/traffic_light.rb
|
118
118
|
- spec/internal/app/models/vehicle.rb
|
119
|
-
- spec/machine_spec.rb
|
120
|
-
- spec/matcher_helpers_spec.rb
|
121
|
-
- spec/matcher_spec.rb
|
122
119
|
- spec/models/auto_shop_spec.rb
|
123
120
|
- spec/models/car_spec.rb
|
124
121
|
- spec/models/motorcycle_spec.rb
|
125
122
|
- spec/models/traffic_light_spec.rb
|
126
123
|
- spec/models/vehicle_spec.rb
|
127
|
-
- spec/node_collection_spec.rb
|
128
|
-
- spec/path_collection_spec.rb
|
129
|
-
- spec/path_spec.rb
|
130
124
|
- spec/spec_helper.rb
|
131
|
-
- spec/
|
132
|
-
- spec/
|
133
|
-
- spec/
|
134
|
-
- spec/
|
125
|
+
- spec/state_machines/assertions_spec.rb
|
126
|
+
- spec/state_machines/branch_spec.rb
|
127
|
+
- spec/state_machines/callbacks_spec.rb
|
128
|
+
- spec/state_machines/errors_spec.rb
|
129
|
+
- spec/state_machines/event_collection_spec.rb
|
130
|
+
- spec/state_machines/event_spec.rb
|
131
|
+
- spec/state_machines/helper_spec.rb
|
132
|
+
- spec/state_machines/integration_base_spec.rb
|
133
|
+
- spec/state_machines/integration_spec.rb
|
134
|
+
- spec/state_machines/invalid_event_spec.rb
|
135
|
+
- spec/state_machines/invalid_parallel_transition_spec.rb
|
136
|
+
- spec/state_machines/invalid_transition_spec.rb
|
137
|
+
- spec/state_machines/machine_collection_spec.rb
|
138
|
+
- spec/state_machines/machine_spec.rb
|
139
|
+
- spec/state_machines/matcher_helpers_spec.rb
|
140
|
+
- spec/state_machines/matcher_spec.rb
|
141
|
+
- spec/state_machines/node_collection_spec.rb
|
142
|
+
- spec/state_machines/path_collection_spec.rb
|
143
|
+
- spec/state_machines/path_spec.rb
|
144
|
+
- spec/state_machines/state_collection_spec.rb
|
145
|
+
- spec/state_machines/state_context_spec.rb
|
146
|
+
- spec/state_machines/state_machine_spec.rb
|
147
|
+
- spec/state_machines/state_spec.rb
|
148
|
+
- spec/state_machines/transition_collection_spec.rb
|
149
|
+
- spec/state_machines/transition_spec.rb
|
135
150
|
- spec/support/migration_helpers.rb
|
136
151
|
- spec/support/models.rb
|
137
|
-
- spec/transition_collection_spec.rb
|
138
|
-
- spec/transition_spec.rb
|
139
152
|
- state_machines.gemspec
|
140
|
-
homepage:
|
153
|
+
homepage: https://github.com/seuros/state_machines
|
141
154
|
licenses:
|
142
155
|
- MIT
|
143
156
|
metadata: {}
|
@@ -149,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
162
|
requirements:
|
150
163
|
- - ">="
|
151
164
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
165
|
+
version: 1.9.3
|
153
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
167
|
requirements:
|
155
168
|
- - ">="
|
@@ -162,33 +175,43 @@ signing_key:
|
|
162
175
|
specification_version: 4
|
163
176
|
summary: State machines for attributes
|
164
177
|
test_files:
|
165
|
-
- spec/errors/default_spec.rb
|
166
|
-
- spec/errors/with_message_spec.rb
|
167
|
-
- spec/helpers/helper_spec.rb
|
168
178
|
- spec/internal/app/models/auto_shop.rb
|
169
179
|
- spec/internal/app/models/car.rb
|
170
180
|
- spec/internal/app/models/model_base.rb
|
171
181
|
- spec/internal/app/models/motorcycle.rb
|
172
182
|
- spec/internal/app/models/traffic_light.rb
|
173
183
|
- spec/internal/app/models/vehicle.rb
|
174
|
-
- spec/machine_spec.rb
|
175
|
-
- spec/matcher_helpers_spec.rb
|
176
|
-
- spec/matcher_spec.rb
|
177
184
|
- spec/models/auto_shop_spec.rb
|
178
185
|
- spec/models/car_spec.rb
|
179
186
|
- spec/models/motorcycle_spec.rb
|
180
187
|
- spec/models/traffic_light_spec.rb
|
181
188
|
- spec/models/vehicle_spec.rb
|
182
|
-
- spec/node_collection_spec.rb
|
183
|
-
- spec/path_collection_spec.rb
|
184
|
-
- spec/path_spec.rb
|
185
189
|
- spec/spec_helper.rb
|
186
|
-
- spec/
|
187
|
-
- spec/
|
188
|
-
- spec/
|
189
|
-
- spec/
|
190
|
+
- spec/state_machines/assertions_spec.rb
|
191
|
+
- spec/state_machines/branch_spec.rb
|
192
|
+
- spec/state_machines/callbacks_spec.rb
|
193
|
+
- spec/state_machines/errors_spec.rb
|
194
|
+
- spec/state_machines/event_collection_spec.rb
|
195
|
+
- spec/state_machines/event_spec.rb
|
196
|
+
- spec/state_machines/helper_spec.rb
|
197
|
+
- spec/state_machines/integration_base_spec.rb
|
198
|
+
- spec/state_machines/integration_spec.rb
|
199
|
+
- spec/state_machines/invalid_event_spec.rb
|
200
|
+
- spec/state_machines/invalid_parallel_transition_spec.rb
|
201
|
+
- spec/state_machines/invalid_transition_spec.rb
|
202
|
+
- spec/state_machines/machine_collection_spec.rb
|
203
|
+
- spec/state_machines/machine_spec.rb
|
204
|
+
- spec/state_machines/matcher_helpers_spec.rb
|
205
|
+
- spec/state_machines/matcher_spec.rb
|
206
|
+
- spec/state_machines/node_collection_spec.rb
|
207
|
+
- spec/state_machines/path_collection_spec.rb
|
208
|
+
- spec/state_machines/path_spec.rb
|
209
|
+
- spec/state_machines/state_collection_spec.rb
|
210
|
+
- spec/state_machines/state_context_spec.rb
|
211
|
+
- spec/state_machines/state_machine_spec.rb
|
212
|
+
- spec/state_machines/state_spec.rb
|
213
|
+
- spec/state_machines/transition_collection_spec.rb
|
214
|
+
- spec/state_machines/transition_spec.rb
|
190
215
|
- spec/support/migration_helpers.rb
|
191
216
|
- spec/support/models.rb
|
192
|
-
- spec/transition_collection_spec.rb
|
193
|
-
- spec/transition_spec.rb
|
194
217
|
has_rdoc:
|
data/lib/state_machines/yard.rb
DELETED
data/spec/errors/default_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'ErrorByDefault' do
|
4
|
-
let(:klass) { Class.new }
|
5
|
-
let(:machine) { StateMachines::Machine.new(klass) }
|
6
|
-
let(:collection) { StateMachines::NodeCollection.new(machine) }
|
7
|
-
it '#length' do
|
8
|
-
expect(collection.length).to eq(0)
|
9
|
-
end
|
10
|
-
|
11
|
-
it do
|
12
|
-
expect(collection.machine).to eq(machine)
|
13
|
-
end
|
14
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'ErrorWithMessage' do
|
4
|
-
let(:klass) { Class.new }
|
5
|
-
let(:machine) { StateMachines::Machine.new(klass) }
|
6
|
-
let(:collection) { StateMachines::NodeCollection.new(machine) }
|
7
|
-
it 'should_raise_exception_if_invalid_option_specified' do
|
8
|
-
expect { StateMachines::NodeCollection.new(machine, invalid: true) }.to raise_error(ArgumentError)
|
9
|
-
# assert_equal 'Invalid key(s): invalid', exception.message
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should_raise_exception_on_lookup_if_invalid_index_specified' do
|
13
|
-
expect { collection[:something, :invalid] }.to raise_error(ArgumentError)
|
14
|
-
# assert_equal 'Invalid index: :invalid', exception.message
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should raise exception on fetch if invalid index specified' do
|
18
|
-
expect { collection[:something, :invalid] }.to raise_error(ArgumentError)
|
19
|
-
# assert_equal 'Invalid index: :invalid', exception.message
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
# class ErrorWithMessageTest < Test::Unit::TestCase
|
24
|
-
#
|
25
|
-
# it 'should_raise_exception_if_invalid_option_specified
|
26
|
-
# exception = assert_raise(ArgumentError) { StateMachines::NodeCollection.new(@machine, :invalid => true) }
|
27
|
-
# assert_equal 'Invalid key(s): invalid', exception.message
|
28
|
-
# end
|
29
|
-
#
|
30
|
-
# it 'should_raise_exception_on_lookup_if_invalid_index_specified
|
31
|
-
# exception = assert_raise(ArgumentError) { @collection[:something, :invalid] }
|
32
|
-
# assert_equal 'Invalid index: :invalid', exception.message
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# it 'should_raise_exception_on_fetch_if_invalid_index_specified
|
36
|
-
# exception = assert_raise(ArgumentError) { @collection.fetch(:something, :invalid) }
|
37
|
-
# assert_equal 'Invalid index: :invalid', exception.message
|
38
|
-
# end
|
39
|
-
# end
|