aasm 4.12.3 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -12
  3. data/Appraisals +39 -16
  4. data/CHANGELOG.md +8 -1
  5. data/Dockerfile +44 -0
  6. data/Gemfile +1 -2
  7. data/README.md +51 -11
  8. data/docker-compose.yml +40 -0
  9. data/gemfiles/rails_3.2.gemfile +6 -6
  10. data/gemfiles/rails_4.0.gemfile +7 -7
  11. data/gemfiles/rails_4.2.gemfile +8 -8
  12. data/gemfiles/rails_4.2_mongoid_5.gemfile +5 -5
  13. data/gemfiles/rails_4.2_nobrainer.gemfile +9 -0
  14. data/gemfiles/rails_5.0.gemfile +5 -6
  15. data/gemfiles/rails_5.0_nobrainer.gemfile +9 -0
  16. data/gemfiles/rails_5.1.gemfile +13 -0
  17. data/lib/aasm.rb +5 -0
  18. data/lib/aasm/aasm.rb +1 -0
  19. data/lib/aasm/core/event.rb +5 -21
  20. data/lib/aasm/core/invoker.rb +129 -0
  21. data/lib/aasm/core/invokers/base_invoker.rb +75 -0
  22. data/lib/aasm/core/invokers/class_invoker.rb +52 -0
  23. data/lib/aasm/core/invokers/literal_invoker.rb +47 -0
  24. data/lib/aasm/core/invokers/proc_invoker.rb +59 -0
  25. data/lib/aasm/core/state.rb +10 -9
  26. data/lib/aasm/core/transition.rb +7 -68
  27. data/lib/aasm/errors.rb +2 -2
  28. data/lib/aasm/persistence.rb +3 -0
  29. data/lib/aasm/persistence/no_brainer_persistence.rb +105 -0
  30. data/lib/aasm/persistence/plain_persistence.rb +2 -1
  31. data/lib/aasm/persistence/sequel_persistence.rb +0 -1
  32. data/lib/aasm/rspec/allow_event.rb +5 -1
  33. data/lib/aasm/rspec/allow_transition_to.rb +5 -1
  34. data/lib/aasm/version.rb +1 -1
  35. data/lib/generators/nobrainer/aasm_generator.rb +28 -0
  36. data/lib/motion-aasm.rb +1 -0
  37. data/spec/generators/no_brainer_generator_spec.rb +29 -0
  38. data/spec/models/nobrainer/complex_no_brainer_example.rb +36 -0
  39. data/spec/models/nobrainer/invalid_persistor_no_brainer.rb +39 -0
  40. data/spec/models/nobrainer/no_scope_no_brainer.rb +21 -0
  41. data/spec/models/nobrainer/nobrainer_relationships.rb +25 -0
  42. data/spec/models/nobrainer/silent_persistor_no_brainer.rb +39 -0
  43. data/spec/models/nobrainer/simple_new_dsl_nobrainer.rb +25 -0
  44. data/spec/models/nobrainer/simple_no_brainer.rb +23 -0
  45. data/spec/models/nobrainer/validator_no_brainer.rb +98 -0
  46. data/spec/models/simple_example.rb +2 -0
  47. data/spec/models/simple_example_with_guard_args.rb +17 -0
  48. data/spec/spec_helpers/active_record.rb +2 -1
  49. data/spec/spec_helpers/dynamoid.rb +7 -5
  50. data/spec/spec_helpers/mongoid.rb +20 -1
  51. data/spec/spec_helpers/nobrainer.rb +15 -0
  52. data/spec/spec_helpers/redis.rb +5 -2
  53. data/spec/spec_helpers/sequel.rb +1 -1
  54. data/spec/unit/callbacks_spec.rb +2 -2
  55. data/spec/unit/exception_spec.rb +1 -1
  56. data/spec/unit/invoker_spec.rb +189 -0
  57. data/spec/unit/invokers/base_invoker_spec.rb +72 -0
  58. data/spec/unit/invokers/class_invoker_spec.rb +95 -0
  59. data/spec/unit/invokers/literal_invoker_spec.rb +86 -0
  60. data/spec/unit/invokers/proc_invoker_spec.rb +86 -0
  61. data/spec/unit/persistence/mongoid_persistence_multiple_spec.rb +0 -4
  62. data/spec/unit/persistence/mongoid_persistence_spec.rb +0 -4
  63. data/spec/unit/persistence/no_brainer_persistence_multiple_spec.rb +198 -0
  64. data/spec/unit/persistence/no_brainer_persistence_spec.rb +158 -0
  65. data/spec/unit/rspec_matcher_spec.rb +6 -0
  66. data/spec/unit/state_spec.rb +2 -2
  67. data/spec/unit/transition_spec.rb +1 -1
  68. data/test/minitest_helper.rb +2 -2
  69. data/test/unit/minitest_matcher_test.rb +1 -1
  70. metadata +51 -3
@@ -63,6 +63,12 @@ describe 'state machine' do
63
63
  expect(simple).to allow_event :authorise
64
64
  end
65
65
 
66
+ it "works with custom arguments" do
67
+ example = SimpleExampleWithGuardArgs.new
68
+ expect(example).to allow_event(:fill_out_with_args).with(true)
69
+ expect(example).to_not allow_event(:fill_out_with_args).with(false)
70
+ end
71
+
66
72
  it "works for multiple state machines" do
67
73
  expect(multiple).to allow_event(:walk).on(:move)
68
74
  expect(multiple).to_not allow_event(:hold).on(:move)
@@ -64,7 +64,7 @@ describe AASM::Core::State do
64
64
  expect(record).to receive(:c)
65
65
  expect(record).to receive(:foobar)
66
66
 
67
- state.fire_callbacks(:entering, record)
67
+ state.fire_callbacks(:entering, record, record)
68
68
  end
69
69
 
70
70
  it "should stop calling actions if one of them raises :halt_aasm_chain" do
@@ -84,6 +84,6 @@ describe AASM::Core::State do
84
84
  record = double('record')
85
85
  expect(record).to receive(:foobar)
86
86
 
87
- state.fire_callbacks(:entering, record)
87
+ state.fire_callbacks(:entering, record, record)
88
88
  end
89
89
  end
@@ -6,7 +6,7 @@ describe 'transitions' do
6
6
  process = ProcessWithNewDsl.new
7
7
  expect { process.stop! }.to raise_error do |err|
8
8
  expect(err.class).to eql(AASM::InvalidTransition)
9
- expect(err.message).to eql("Event 'stop' cannot transition from 'sleeping'. ")
9
+ expect(err.message).to eql("Event 'stop' cannot transition from 'sleeping'.")
10
10
  expect(err.object).to eql(process)
11
11
  expect(err.event_name).to eql(:stop)
12
12
  end
@@ -34,8 +34,8 @@ begin
34
34
  })
35
35
 
36
36
  Dynamoid.configure do |config|
37
- config.namespace = "dynamoid_tests"
38
- config.endpoint = 'http://127.0.0.1:30180'
37
+ config.namespace = 'dynamoid_tests'
38
+ config.endpoint = "http://#{ENV['DYNAMODB_HOST'] || '127.0.0.1'}:30180"
39
39
  config.warn_on_scan = false
40
40
  end
41
41
 
@@ -1,7 +1,7 @@
1
1
  require 'minitest_helper'
2
2
 
3
3
  class StateMachineTest < Minitest::Spec
4
-
4
+
5
5
  let(:simple) { SimpleExample.new }
6
6
  let(:multiple) { SimpleMultipleExample.new }
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.3
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Boettger
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-10-24 00:00:00.000000000 Z
12
+ date: 2018-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: concurrent-ruby
@@ -124,6 +124,7 @@ files:
124
124
  - CHANGELOG.md
125
125
  - CODE_OF_CONDUCT.md
126
126
  - CONTRIBUTING.md
127
+ - Dockerfile
127
128
  - Gemfile
128
129
  - Gemfile.lock_old
129
130
  - HOWTO
@@ -135,16 +136,25 @@ files:
135
136
  - TESTING.md
136
137
  - aasm.gemspec
137
138
  - callbacks.txt
139
+ - docker-compose.yml
138
140
  - gemfiles/rails_3.2.gemfile
139
141
  - gemfiles/rails_4.0.gemfile
140
142
  - gemfiles/rails_4.2.gemfile
141
143
  - gemfiles/rails_4.2_mongoid_5.gemfile
144
+ - gemfiles/rails_4.2_nobrainer.gemfile
142
145
  - gemfiles/rails_5.0.gemfile
146
+ - gemfiles/rails_5.0_nobrainer.gemfile
147
+ - gemfiles/rails_5.1.gemfile
143
148
  - lib/aasm.rb
144
149
  - lib/aasm/aasm.rb
145
150
  - lib/aasm/base.rb
146
151
  - lib/aasm/configuration.rb
147
152
  - lib/aasm/core/event.rb
153
+ - lib/aasm/core/invoker.rb
154
+ - lib/aasm/core/invokers/base_invoker.rb
155
+ - lib/aasm/core/invokers/class_invoker.rb
156
+ - lib/aasm/core/invokers/literal_invoker.rb
157
+ - lib/aasm/core/invokers/proc_invoker.rb
148
158
  - lib/aasm/core/state.rb
149
159
  - lib/aasm/core/transition.rb
150
160
  - lib/aasm/dsl_helper.rb
@@ -163,6 +173,7 @@ files:
163
173
  - lib/aasm/persistence/core_data_query_persistence.rb
164
174
  - lib/aasm/persistence/dynamoid_persistence.rb
165
175
  - lib/aasm/persistence/mongoid_persistence.rb
176
+ - lib/aasm/persistence/no_brainer_persistence.rb
166
177
  - lib/aasm/persistence/orm.rb
167
178
  - lib/aasm/persistence/plain_persistence.rb
168
179
  - lib/aasm/persistence/redis_persistence.rb
@@ -181,6 +192,7 @@ files:
181
192
  - lib/generators/active_record/templates/migration.rb
182
193
  - lib/generators/active_record/templates/migration_existing.rb
183
194
  - lib/generators/mongoid/aasm_generator.rb
195
+ - lib/generators/nobrainer/aasm_generator.rb
184
196
  - lib/motion-aasm.rb
185
197
  - spec/database.rb
186
198
  - spec/database.yml
@@ -188,6 +200,7 @@ files:
188
200
  - spec/en_deprecated_style.yml
189
201
  - spec/generators/active_record_generator_spec.rb
190
202
  - spec/generators/mongoid_generator_spec.rb
203
+ - spec/generators/no_brainer_generator_spec.rb
191
204
  - spec/models/active_record/basic_active_record_two_state_machines_example.rb
192
205
  - spec/models/active_record/complex_active_record_example.rb
193
206
  - spec/models/active_record/derivate_new_dsl.rb
@@ -254,6 +267,14 @@ files:
254
267
  - spec/models/multiple_transitions_that_differ_only_by_guard.rb
255
268
  - spec/models/namespaced_multiple_example.rb
256
269
  - spec/models/no_initial_state.rb
270
+ - spec/models/nobrainer/complex_no_brainer_example.rb
271
+ - spec/models/nobrainer/invalid_persistor_no_brainer.rb
272
+ - spec/models/nobrainer/no_scope_no_brainer.rb
273
+ - spec/models/nobrainer/nobrainer_relationships.rb
274
+ - spec/models/nobrainer/silent_persistor_no_brainer.rb
275
+ - spec/models/nobrainer/simple_new_dsl_nobrainer.rb
276
+ - spec/models/nobrainer/simple_no_brainer.rb
277
+ - spec/models/nobrainer/validator_no_brainer.rb
257
278
  - spec/models/not_auto_loaded/process.rb
258
279
  - spec/models/parametrised_event.rb
259
280
  - spec/models/parametrised_event_multiple.rb
@@ -273,6 +294,7 @@ files:
273
294
  - spec/models/silencer.rb
274
295
  - spec/models/simple_custom_example.rb
275
296
  - spec/models/simple_example.rb
297
+ - spec/models/simple_example_with_guard_args.rb
276
298
  - spec/models/simple_multiple_example.rb
277
299
  - spec/models/state_machine_with_failed_event.rb
278
300
  - spec/models/states_on_one_line_example.rb
@@ -286,6 +308,7 @@ files:
286
308
  - spec/spec_helpers/active_record.rb
287
309
  - spec/spec_helpers/dynamoid.rb
288
310
  - spec/spec_helpers/mongoid.rb
311
+ - spec/spec_helpers/nobrainer.rb
289
312
  - spec/spec_helpers/redis.rb
290
313
  - spec/spec_helpers/remove_warnings.rb
291
314
  - spec/spec_helpers/sequel.rb
@@ -310,6 +333,11 @@ files:
310
333
  - spec/unit/initial_state_spec.rb
311
334
  - spec/unit/inspection_multiple_spec.rb
312
335
  - spec/unit/inspection_spec.rb
336
+ - spec/unit/invoker_spec.rb
337
+ - spec/unit/invokers/base_invoker_spec.rb
338
+ - spec/unit/invokers/class_invoker_spec.rb
339
+ - spec/unit/invokers/literal_invoker_spec.rb
340
+ - spec/unit/invokers/proc_invoker_spec.rb
313
341
  - spec/unit/localizer_spec.rb
314
342
  - spec/unit/memory_leak_spec.rb
315
343
  - spec/unit/multiple_transitions_that_differ_only_by_guard_spec.rb
@@ -322,6 +350,8 @@ files:
322
350
  - spec/unit/persistence/dynamoid_persistence_spec.rb
323
351
  - spec/unit/persistence/mongoid_persistence_multiple_spec.rb
324
352
  - spec/unit/persistence/mongoid_persistence_spec.rb
353
+ - spec/unit/persistence/no_brainer_persistence_multiple_spec.rb
354
+ - spec/unit/persistence/no_brainer_persistence_spec.rb
325
355
  - spec/unit/persistence/redis_persistence_multiple_spec.rb
326
356
  - spec/unit/persistence/redis_persistence_spec.rb
327
357
  - spec/unit/persistence/sequel_persistence_multiple_spec.rb
@@ -359,7 +389,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
389
  version: '0'
360
390
  requirements: []
361
391
  rubyforge_project:
362
- rubygems_version: 2.6.12
392
+ rubygems_version: 2.6.14
363
393
  signing_key:
364
394
  specification_version: 4
365
395
  summary: State machine mixin for Ruby objects
@@ -370,6 +400,7 @@ test_files:
370
400
  - spec/en_deprecated_style.yml
371
401
  - spec/generators/active_record_generator_spec.rb
372
402
  - spec/generators/mongoid_generator_spec.rb
403
+ - spec/generators/no_brainer_generator_spec.rb
373
404
  - spec/models/active_record/basic_active_record_two_state_machines_example.rb
374
405
  - spec/models/active_record/complex_active_record_example.rb
375
406
  - spec/models/active_record/derivate_new_dsl.rb
@@ -436,6 +467,14 @@ test_files:
436
467
  - spec/models/multiple_transitions_that_differ_only_by_guard.rb
437
468
  - spec/models/namespaced_multiple_example.rb
438
469
  - spec/models/no_initial_state.rb
470
+ - spec/models/nobrainer/complex_no_brainer_example.rb
471
+ - spec/models/nobrainer/invalid_persistor_no_brainer.rb
472
+ - spec/models/nobrainer/no_scope_no_brainer.rb
473
+ - spec/models/nobrainer/nobrainer_relationships.rb
474
+ - spec/models/nobrainer/silent_persistor_no_brainer.rb
475
+ - spec/models/nobrainer/simple_new_dsl_nobrainer.rb
476
+ - spec/models/nobrainer/simple_no_brainer.rb
477
+ - spec/models/nobrainer/validator_no_brainer.rb
439
478
  - spec/models/not_auto_loaded/process.rb
440
479
  - spec/models/parametrised_event.rb
441
480
  - spec/models/parametrised_event_multiple.rb
@@ -455,6 +494,7 @@ test_files:
455
494
  - spec/models/silencer.rb
456
495
  - spec/models/simple_custom_example.rb
457
496
  - spec/models/simple_example.rb
497
+ - spec/models/simple_example_with_guard_args.rb
458
498
  - spec/models/simple_multiple_example.rb
459
499
  - spec/models/state_machine_with_failed_event.rb
460
500
  - spec/models/states_on_one_line_example.rb
@@ -468,6 +508,7 @@ test_files:
468
508
  - spec/spec_helpers/active_record.rb
469
509
  - spec/spec_helpers/dynamoid.rb
470
510
  - spec/spec_helpers/mongoid.rb
511
+ - spec/spec_helpers/nobrainer.rb
471
512
  - spec/spec_helpers/redis.rb
472
513
  - spec/spec_helpers/remove_warnings.rb
473
514
  - spec/spec_helpers/sequel.rb
@@ -492,6 +533,11 @@ test_files:
492
533
  - spec/unit/initial_state_spec.rb
493
534
  - spec/unit/inspection_multiple_spec.rb
494
535
  - spec/unit/inspection_spec.rb
536
+ - spec/unit/invoker_spec.rb
537
+ - spec/unit/invokers/base_invoker_spec.rb
538
+ - spec/unit/invokers/class_invoker_spec.rb
539
+ - spec/unit/invokers/literal_invoker_spec.rb
540
+ - spec/unit/invokers/proc_invoker_spec.rb
495
541
  - spec/unit/localizer_spec.rb
496
542
  - spec/unit/memory_leak_spec.rb
497
543
  - spec/unit/multiple_transitions_that_differ_only_by_guard_spec.rb
@@ -504,6 +550,8 @@ test_files:
504
550
  - spec/unit/persistence/dynamoid_persistence_spec.rb
505
551
  - spec/unit/persistence/mongoid_persistence_multiple_spec.rb
506
552
  - spec/unit/persistence/mongoid_persistence_spec.rb
553
+ - spec/unit/persistence/no_brainer_persistence_multiple_spec.rb
554
+ - spec/unit/persistence/no_brainer_persistence_spec.rb
507
555
  - spec/unit/persistence/redis_persistence_multiple_spec.rb
508
556
  - spec/unit/persistence/redis_persistence_spec.rb
509
557
  - spec/unit/persistence/sequel_persistence_multiple_spec.rb