transitions 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +18 -1
  3. data/.travis.yml +5 -0
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +7 -6
  6. data/LICENSE.txt +21 -0
  7. data/README.md +9 -4
  8. data/Rakefile +9 -4
  9. data/bin/console +7 -0
  10. data/lib/active_model/transitions.rb +19 -12
  11. data/lib/transitions.rb +15 -15
  12. data/lib/transitions/event.rb +19 -15
  13. data/lib/transitions/machine.rb +23 -22
  14. data/lib/transitions/presenter.rb +2 -6
  15. data/lib/transitions/state.rb +10 -7
  16. data/lib/transitions/state_transition.rb +37 -6
  17. data/lib/transitions/version.rb +1 -1
  18. data/transitions.gemspec +23 -24
  19. metadata +39 -45
  20. data/.ruby-gemset +0 -1
  21. data/MIT-LICENSE.txt +0 -21
  22. data/test/active_record/test_active_record.rb +0 -326
  23. data/test/active_record/test_active_record_scopes.rb +0 -64
  24. data/test/active_record/test_active_record_timestamps.rb +0 -132
  25. data/test/active_record/test_custom_select.rb +0 -33
  26. data/test/event/test_event.rb +0 -72
  27. data/test/event/test_event_arguments.rb +0 -29
  28. data/test/event/test_event_being_fired.rb +0 -26
  29. data/test/event/test_event_checks.rb +0 -33
  30. data/test/helper.rb +0 -18
  31. data/test/machine/machine_template.rb +0 -27
  32. data/test/machine/test_available_states_listing.rb +0 -24
  33. data/test/machine/test_fire_event_machine.rb +0 -29
  34. data/test/machine/test_machine.rb +0 -66
  35. data/test/state/test_state.rb +0 -71
  36. data/test/state/test_state_predicate_method.rb +0 -32
  37. data/test/state_transition/test_state_transition.rb +0 -45
  38. data/test/state_transition/test_state_transition_event_failed_callback.rb +0 -36
  39. data/test/state_transition/test_state_transition_event_fired_callback.rb +0 -44
  40. data/test/state_transition/test_state_transition_guard_check.rb +0 -66
  41. data/test/state_transition/test_state_transition_on_transition_callback.rb +0 -48
  42. data/test/state_transition/test_state_transition_success_callback.rb +0 -49
@@ -1,49 +0,0 @@
1
- require 'helper'
2
-
3
- class DrivingInstructor
4
- def self.applause!
5
- end
6
- end
7
-
8
- class DrivingSchoolCar
9
- include Transitions
10
-
11
- state_machine do
12
- state :parked
13
- state :running
14
- state :driving
15
- state :switched_off
16
-
17
- event :start_driving, success: lambda { |_car| DrivingInstructor.applause! } do
18
- transitions from: :parked, to: :driving, on_transition: [:start_engine, :loosen_handbrake, :push_gas_pedal]
19
- end
20
-
21
- event :switch_off_engine do
22
- transitions from: :parked, to: :switched_off
23
- end
24
- end
25
-
26
- %w(start_engine loosen_handbrake push_gas_pedal).each do |m|
27
- define_method(m) {}
28
- end
29
- end
30
-
31
- class TestStateTransitionSuccessCallback < Test::Unit::TestCase
32
- def setup
33
- @car = DrivingSchoolCar.new
34
- end
35
-
36
- test 'should execute the success callback after successfull event execution' do
37
- DrivingInstructor.expects(:applause!)
38
-
39
- @car.start_driving!
40
- end
41
-
42
- test 'should not execute the success callback after event execution failed' do
43
- DrivingInstructor.expects(:applause!).never
44
-
45
- @car.stubs(:event_failed)
46
- @car.expects(:loosen_handbrake).raises('Drive with handbrake fail!')
47
- @car.start_driving!
48
- end
49
- end