transitions 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.travis.yml +3 -1
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +7 -2
  6. data/README.md +1 -1
  7. data/Rakefile +4 -4
  8. data/lib/active_model/transitions.rb +8 -8
  9. data/lib/transitions/event.rb +15 -16
  10. data/lib/transitions/machine.rb +4 -5
  11. data/lib/transitions/presenter.rb +1 -1
  12. data/lib/transitions/state.rb +2 -1
  13. data/lib/transitions/state_transition.rb +2 -2
  14. data/lib/transitions/version.rb +1 -1
  15. data/lib/transitions.rb +10 -8
  16. data/test/active_record/test_active_record.rb +64 -66
  17. data/test/active_record/test_active_record_scopes.rb +7 -7
  18. data/test/active_record/test_active_record_timestamps.rb +27 -28
  19. data/test/active_record/test_custom_select.rb +3 -3
  20. data/test/event/test_event.rb +20 -20
  21. data/test/event/test_event_arguments.rb +3 -4
  22. data/test/event/test_event_being_fired.rb +4 -4
  23. data/test/event/test_event_checks.rb +5 -6
  24. data/test/helper.rb +1 -1
  25. data/test/machine/machine_template.rb +4 -4
  26. data/test/machine/test_available_states_listing.rb +1 -1
  27. data/test/machine/test_fire_event_machine.rb +5 -5
  28. data/test/machine/test_machine.rb +10 -10
  29. data/test/state/test_state.rb +16 -16
  30. data/test/state/test_state_predicate_method.rb +2 -2
  31. data/test/state_transition/test_state_transition.rb +11 -11
  32. data/test/state_transition/test_state_transition_event_failed_callback.rb +3 -3
  33. data/test/state_transition/test_state_transition_event_fired_callback.rb +3 -3
  34. data/test/state_transition/test_state_transition_guard_check.rb +14 -15
  35. data/test/state_transition/test_state_transition_on_transition_callback.rb +4 -4
  36. data/test/state_transition/test_state_transition_success_callback.rb +8 -8
  37. data/transitions.gemspec +16 -16
  38. metadata +4 -3
@@ -1,4 +1,4 @@
1
- require "helper"
1
+ require 'helper'
2
2
 
3
3
  class ArgumentsTestSubject
4
4
  include Transitions
@@ -9,7 +9,7 @@ class ArgumentsTestSubject
9
9
  state :opened
10
10
 
11
11
  event :open do
12
- transitions :from => :initial, :to => :opened, :on_transition => :update_date
12
+ transitions from: :initial, to: :opened, on_transition: :update_date
13
13
  end
14
14
  end
15
15
 
@@ -19,7 +19,7 @@ class ArgumentsTestSubject
19
19
  end
20
20
 
21
21
  class StateMachineMachineTest < Test::Unit::TestCase
22
- test "pass arguments to transition method" do
22
+ test 'pass arguments to transition method' do
23
23
  subject = ArgumentsTestSubject.new
24
24
  assert_equal :initial, subject.current_state
25
25
  subject.open!(Date.yesterday)
@@ -27,4 +27,3 @@ class StateMachineMachineTest < Test::Unit::TestCase
27
27
  assert_equal Date.yesterday, subject.date
28
28
  end
29
29
  end
30
-
@@ -1,7 +1,7 @@
1
- require "helper"
1
+ require 'helper'
2
2
 
3
3
  class TestEventBeingFired < Test::Unit::TestCase
4
- test "should raise an Transitions::InvalidTransition error if the transitions are empty" do
4
+ test 'should raise an Transitions::InvalidTransition error if the transitions are empty' do
5
5
  event = Transitions::Event.new(nil, :event_that_is_fired)
6
6
  class AnotherDummy; end
7
7
  obj = AnotherDummy.new
@@ -13,9 +13,9 @@ class TestEventBeingFired < Test::Unit::TestCase
13
13
  assert_match /Can't fire event `event_that_is_fired` in current state `running` for `TestEventBeingFired::AnotherDummy`/, exception.message
14
14
  end
15
15
 
16
- test "should return the state of the first matching transition it finds" do
16
+ test 'should return the state of the first matching transition it finds' do
17
17
  event = Transitions::Event.new(nil, :event) do
18
- transitions :to => :closed, :from => [:open, :received]
18
+ transitions to: :closed, from: [:open, :received]
19
19
  end
20
20
 
21
21
  obj = stub
@@ -1,25 +1,25 @@
1
- require "helper"
1
+ require 'helper'
2
2
 
3
3
  class ChecksTestSubject
4
4
  include Transitions
5
5
 
6
- state_machine :initial => :initial do
6
+ state_machine initial: :initial do
7
7
  state :initial
8
8
  state :opened
9
9
  state :closed
10
10
 
11
11
  event :open do
12
- transitions :from => :initial, :to => :opened
12
+ transitions from: :initial, to: :opened
13
13
  end
14
14
 
15
15
  event :close do
16
- transitions :from => :opened, :to => :closed
16
+ transitions from: :opened, to: :closed
17
17
  end
18
18
  end
19
19
  end
20
20
 
21
21
  class StateMachineChecksTest < Test::Unit::TestCase
22
- test "checks if a given transition is possible" do
22
+ test 'checks if a given transition is possible' do
23
23
  subject = ChecksTestSubject.new
24
24
  assert_equal :initial, subject.current_state
25
25
  assert_equal true, subject.can_open?
@@ -31,4 +31,3 @@ class StateMachineChecksTest < Test::Unit::TestCase
31
31
  assert_equal true, subject.can_close?
32
32
  end
33
33
  end
34
-
data/test/helper.rb CHANGED
@@ -8,7 +8,7 @@ require 'mocha'
8
8
  require 'random_data'
9
9
 
10
10
  def db_defaults!
11
- ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
11
+ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
12
12
  ActiveRecord::Migration.verbose = false
13
13
  end
14
14
 
@@ -1,20 +1,20 @@
1
1
  class MachineTestSubject
2
2
  include Transitions
3
3
 
4
- state_machine :initial => :open do
4
+ state_machine initial: :open do
5
5
  state :open
6
6
  state :closed
7
7
 
8
8
  event :shutdown do
9
- transitions :from => :open, :to => :closed
9
+ transitions from: :open, to: :closed
10
10
  end
11
11
 
12
12
  event :timeout do
13
- transitions :from => :open, :to => :closed
13
+ transitions from: :open, to: :closed
14
14
  end
15
15
 
16
16
  event :restart do
17
- transitions :from => :closed, to: :open, guard: :restart_allowed?
17
+ transitions from: :closed, to: :open, guard: :restart_allowed?
18
18
  end
19
19
  end
20
20
 
@@ -1,4 +1,4 @@
1
- require "helper"
1
+ require 'helper'
2
2
 
3
3
  class Bender
4
4
  include Transitions
@@ -1,5 +1,5 @@
1
- require "helper"
2
- require_relative "./machine_template"
1
+ require 'helper'
2
+ require_relative './machine_template'
3
3
 
4
4
  class TestFireEventMachine < Test::Unit::TestCase
5
5
  def setup
@@ -9,19 +9,19 @@ class TestFireEventMachine < Test::Unit::TestCase
9
9
  assert_not_nil @event
10
10
  end
11
11
 
12
- test "fire_event returns true if state transition was successful" do
12
+ test 'fire_event returns true if state transition was successful' do
13
13
  @machine.stubs(:transition_to_new_state).returns(:closed)
14
14
 
15
15
  assert_equal true, @machine.fire_event(@event, @record, false)
16
16
  end
17
17
 
18
- test "fire_event returns false if state transition was unsuccessful" do
18
+ test 'fire_event returns false if state transition was unsuccessful' do
19
19
  @machine.stubs(:transition_to_new_state).returns(false)
20
20
 
21
21
  assert_equal false, @machine.fire_event(@event, @record, false)
22
22
  end
23
23
 
24
- test "fire_event returns false if state transition raises" do
24
+ test 'fire_event returns false if state transition raises' do
25
25
  @machine.stubs(:transition_to_new_state).raises(StandardError)
26
26
 
27
27
  assert_equal false, @machine.fire_event(@event, @record, false)
@@ -1,22 +1,22 @@
1
- require "helper"
1
+ require 'helper'
2
2
 
3
3
  class MachineTestSubject
4
4
  include Transitions
5
5
 
6
- state_machine :initial => :closed do
6
+ state_machine initial: :closed do
7
7
  state :open
8
8
  state :closed
9
9
 
10
10
  event :shutdown do
11
- transitions :from => :open, :to => :closed
11
+ transitions from: :open, to: :closed
12
12
  end
13
13
 
14
14
  event :timeout do
15
- transitions :from => :open, :to => :closed
15
+ transitions from: :open, to: :closed
16
16
  end
17
17
 
18
18
  event :restart do
19
- transitions :from => :closed, to: :open, guard: :restart_allowed?
19
+ transitions from: :closed, to: :open, guard: :restart_allowed?
20
20
  end
21
21
  end
22
22
 
@@ -26,28 +26,28 @@ class MachineTestSubject
26
26
  end
27
27
 
28
28
  class TransitionsMachineTest < Test::Unit::TestCase
29
- test "sets #initial_state from :initial option" do
29
+ test 'sets #initial_state from :initial option' do
30
30
  assert_equal :closed, MachineTestSubject.get_state_machine.initial_state
31
31
  end
32
32
 
33
- test "`get_state_machine` returns Transitions::Machine" do
33
+ test '`get_state_machine` returns Transitions::Machine' do
34
34
  assert_kind_of Transitions::Machine, MachineTestSubject.get_state_machine
35
35
  end
36
36
 
37
- test "finds events for given state" do
37
+ test 'finds events for given state' do
38
38
  events = MachineTestSubject.get_state_machine.events_for(:open)
39
39
  assert events.include?(:shutdown)
40
40
  assert events.include?(:timeout)
41
41
  end
42
42
 
43
- test "knows all available transitions for current state" do
43
+ test 'knows all available transitions for current state' do
44
44
  machine = MachineTestSubject.new
45
45
  assert_equal [:restart], machine.available_transitions
46
46
  machine.restart
47
47
  assert_equal [:shutdown, :timeout], machine.available_transitions
48
48
  end
49
49
 
50
- test "knows that it can use a transition when it is available" do
50
+ test 'knows that it can use a transition when it is available' do
51
51
  machine = MachineTestSubject.new
52
52
  machine.restart
53
53
  assert machine.can_transition?(:shutdown)
@@ -1,4 +1,4 @@
1
- require "helper"
1
+ require 'helper'
2
2
 
3
3
  class TestState < Test::Unit::TestCase
4
4
  def setup
@@ -8,7 +8,7 @@ class TestState < Test::Unit::TestCase
8
8
  end
9
9
  end.get_state_machine
10
10
  state_name = :astate
11
- @options = { :machine => machine, :custom_key => :my_key }
11
+ @options = { machine: machine, custom_key: :my_key }
12
12
  @state = Transitions::State.new(state_name, @options)
13
13
  end
14
14
 
@@ -16,34 +16,34 @@ class TestState < Test::Unit::TestCase
16
16
  Random.alphanumeric(16)
17
17
  end
18
18
 
19
- test "sets the name" do
19
+ test 'sets the name' do
20
20
  assert_equal :astate, @state.name
21
21
  end
22
22
 
23
- test "sets the display_name from name" do
24
- assert_equal "Astate", @state.display_name
23
+ test 'sets the display_name from name' do
24
+ assert_equal 'Astate', @state.display_name
25
25
  end
26
26
 
27
- test "sets the display_name from options" do
28
- assert_equal "A State", Transitions::State.new(new_state_name, @options.merge(:display => "A State")).display_name
27
+ test 'sets the display_name from options' do
28
+ assert_equal 'A State', Transitions::State.new(new_state_name, @options.merge(display: 'A State')).display_name
29
29
  end
30
30
 
31
- test "sets the options and expose them as options" do
31
+ test 'sets the options and expose them as options' do
32
32
  @options.delete(:machine)
33
33
  state = Transitions::State.new new_state_name, @options
34
34
  assert_equal @options, state.options
35
35
  end
36
36
 
37
- test "equals a symbol of the same name" do
37
+ test 'equals a symbol of the same name' do
38
38
  assert_equal @state, :astate
39
39
  end
40
40
 
41
- test "equals a State of the same name" do
41
+ test 'equals a State of the same name' do
42
42
  assert_equal @state, @state
43
43
  end
44
44
 
45
- test "should send a message to the record for an action if the action is present as a symbol" do
46
- state = Transitions::State.new new_state_name, @options.merge(:entering => :foo)
45
+ test 'should send a message to the record for an action if the action is present as a symbol' do
46
+ state = Transitions::State.new new_state_name, @options.merge(entering: :foo)
47
47
 
48
48
  record = stub
49
49
  record.expects(:foo)
@@ -51,8 +51,8 @@ class TestState < Test::Unit::TestCase
51
51
  state.call_action(:entering, record)
52
52
  end
53
53
 
54
- test "should send a message to the record for an action if the action is present as a string" do
55
- state = Transitions::State.new new_state_name, @options.merge(:entering => "foo")
54
+ test 'should send a message to the record for an action if the action is present as a string' do
55
+ state = Transitions::State.new new_state_name, @options.merge(entering: 'foo')
56
56
 
57
57
  record = stub
58
58
  record.expects(:foo)
@@ -60,8 +60,8 @@ class TestState < Test::Unit::TestCase
60
60
  state.call_action(:entering, record)
61
61
  end
62
62
 
63
- test "should call a proc, passing in the record for an action if the action is present" do
64
- state = Transitions::State.new new_state_name, @options.merge(:entering => Proc.new {|r| r.foobar})
63
+ test 'should call a proc, passing in the record for an action if the action is present' do
64
+ state = Transitions::State.new new_state_name, @options.merge(entering: proc(&:foobar))
65
65
 
66
66
  record = stub
67
67
  record.expects(:foobar)
@@ -1,4 +1,4 @@
1
- require "helper"
1
+ require 'helper'
2
2
 
3
3
  class Bus
4
4
  include Transitions
@@ -13,7 +13,7 @@ class TestStatePredicateMethod < Test::Unit::TestCase
13
13
  @bus = Bus.new
14
14
  end
15
15
 
16
- test "should generate predicate methods for states" do
16
+ test 'should generate predicate methods for states' do
17
17
  assert_true @bus.respond_to?(:parking?)
18
18
  assert_true @bus.send(:parking?)
19
19
  end
@@ -1,8 +1,8 @@
1
- require "helper"
1
+ require 'helper'
2
2
 
3
3
  class TestStateTransition < Test::Unit::TestCase
4
- test "should set from, to, and opts attr readers" do
5
- opts = {:from => "foo", :to => "bar", :guard => "g"}
4
+ test 'should set from, to, and opts attr readers' do
5
+ opts = { from: 'foo', to: 'bar', guard: 'g' }
6
6
  st = Transitions::StateTransition.new(opts)
7
7
 
8
8
  assert_equal opts[:from], st.from
@@ -10,8 +10,8 @@ class TestStateTransition < Test::Unit::TestCase
10
10
  assert_equal opts, st.options
11
11
  end
12
12
 
13
- test "should pass equality check if from and to are the same" do
14
- opts = {:from => "foo", :to => "bar", :guard => "g"}
13
+ test 'should pass equality check if from and to are the same' do
14
+ opts = { from: 'foo', to: 'bar', guard: 'g' }
15
15
  st = Transitions::StateTransition.new(opts)
16
16
 
17
17
  obj = stub
@@ -21,24 +21,24 @@ class TestStateTransition < Test::Unit::TestCase
21
21
  assert_equal st, obj
22
22
  end
23
23
 
24
- test "should fail equality check if from are not the same" do
25
- opts = {:from => "foo", :to => "bar", :guard => "g"}
24
+ test 'should fail equality check if from are not the same' do
25
+ opts = { from: 'foo', to: 'bar', guard: 'g' }
26
26
  st = Transitions::StateTransition.new(opts)
27
27
 
28
28
  obj = stub
29
- obj.stubs(:from).returns("blah")
29
+ obj.stubs(:from).returns('blah')
30
30
  obj.stubs(:to).returns(opts[:to])
31
31
 
32
32
  assert_not_equal st, obj
33
33
  end
34
34
 
35
- test "should fail equality check if to are not the same" do
36
- opts = {:from => "foo", :to => "bar", :guard => "g"}
35
+ test 'should fail equality check if to are not the same' do
36
+ opts = { from: 'foo', to: 'bar', guard: 'g' }
37
37
  st = Transitions::StateTransition.new(opts)
38
38
 
39
39
  obj = stub
40
40
  obj.stubs(:from).returns(opts[:from])
41
- obj.stubs(:to).returns("blah")
41
+ obj.stubs(:to).returns('blah')
42
42
 
43
43
  assert_not_equal st, obj
44
44
  end
@@ -9,11 +9,11 @@ class Car
9
9
  state :switched_off
10
10
 
11
11
  event :start_driving do
12
- transitions :from => :parked, :to => :driving
12
+ transitions from: :parked, to: :driving
13
13
  end
14
14
 
15
15
  event :switch_off_engine do
16
- transitions :from => :parked, :to => :switched_off
16
+ transitions from: :parked, to: :switched_off
17
17
  end
18
18
  end
19
19
  end
@@ -23,7 +23,7 @@ class TestStateTransitionEventFailedCallback < Test::Unit::TestCase
23
23
  @car = Car.new
24
24
  end
25
25
 
26
- test "should execute the event_failed_callback and don't raise error if callback is defined" do
26
+ test "should execute the event_failed_callback and don't raise error if callback is defined" do
27
27
  @car.start_driving
28
28
  @car.expects(:event_failed).with(:switch_off_engine)
29
29
  @car.switch_off_engine
@@ -8,7 +8,7 @@ class Car
8
8
  state :driving
9
9
 
10
10
  event :start_driving do
11
- transitions :from => :parked, :to => :driving
11
+ transitions from: :parked, to: :driving
12
12
  end
13
13
  end
14
14
  end
@@ -18,14 +18,14 @@ class TestStateTransitionEventFiredCallback < Test::Unit::TestCase
18
18
  @car = Car.new
19
19
  end
20
20
 
21
- test "should execute the event_fired callback after successfull event execution if it callback is defined" do
21
+ test 'should execute the event_fired callback after successfull event execution if it callback is defined' do
22
22
  @car.stubs(:event_fired)
23
23
  @car.expects(:event_fired).with(:parked, :driving, :start_driving).once
24
24
 
25
25
  @car.start_driving!
26
26
  end
27
27
 
28
- test "should not execute the event_fired callback after successfull event execution if it callback is not defined" do
28
+ test 'should not execute the event_fired callback after successfull event execution if it callback is not defined' do
29
29
  pend 'Test fails right now although functionality is working as expected'
30
30
  # This test fails right now even though it works as expected in the console.
31
31
  # The reason for this is, that mocha's `expects` does a little bit more than just set up an expectation,
@@ -1,17 +1,17 @@
1
- require "helper"
1
+ require 'helper'
2
2
 
3
3
  class TestStateTransitionGuardCheck < Test::Unit::TestCase
4
- args = [:foo, "bar"]
4
+ args = [:foo, 'bar']
5
5
 
6
- test "should return true of there is no guard" do
7
- opts = {:from => "foo", :to => "bar"}
6
+ test 'should return true of there is no guard' do
7
+ opts = { from: 'foo', to: 'bar' }
8
8
  st = Transitions::StateTransition.new(opts)
9
9
 
10
10
  assert st.executable?(nil, *args)
11
11
  end
12
12
 
13
- test "should call the method on the object if guard is a symbol" do
14
- opts = {:from => "foo", :to => "bar", :guard => :test_guard}
13
+ test 'should call the method on the object if guard is a symbol' do
14
+ opts = { from: 'foo', to: 'bar', guard: :test_guard }
15
15
  st = Transitions::StateTransition.new(opts)
16
16
 
17
17
  obj = stub
@@ -20,8 +20,8 @@ class TestStateTransitionGuardCheck < Test::Unit::TestCase
20
20
  st.executable?(obj, *args)
21
21
  end
22
22
 
23
- test "should call the method on the object if guard is a string" do
24
- opts = {:from => "foo", :to => "bar", :guard => "test_guard"}
23
+ test 'should call the method on the object if guard is a string' do
24
+ opts = { from: 'foo', to: 'bar', guard: 'test_guard' }
25
25
  st = Transitions::StateTransition.new(opts)
26
26
 
27
27
  obj = stub
@@ -30,8 +30,8 @@ class TestStateTransitionGuardCheck < Test::Unit::TestCase
30
30
  st.executable?(obj, *args)
31
31
  end
32
32
 
33
- test "should call the proc passing the object if the guard is a proc" do
34
- opts = {:from => "foo", :to => "bar", :guard => Proc.new {|o, *args| o.test_guard(*args)}}
33
+ test 'should call the proc passing the object if the guard is a proc' do
34
+ opts = { from: 'foo', to: 'bar', guard: proc { |o, *args| o.test_guard(*args) } }
35
35
  st = Transitions::StateTransition.new(opts)
36
36
 
37
37
  obj = stub
@@ -40,11 +40,11 @@ class TestStateTransitionGuardCheck < Test::Unit::TestCase
40
40
  st.executable?(obj, *args)
41
41
  end
42
42
 
43
- test "should call the callable passing the object if the guard responds to #call" do
43
+ test 'should call the callable passing the object if the guard responds to #call' do
44
44
  callable = Object.new
45
45
  callable.define_singleton_method(:call) { |obj, *args| obj.test_guard(*args) }
46
46
 
47
- opts = {:from => "foo", :to => "bar", :guard => callable }
47
+ opts = { from: 'foo', to: 'bar', guard: callable }
48
48
  st = Transitions::StateTransition.new(opts)
49
49
 
50
50
  obj = stub
@@ -53,8 +53,8 @@ class TestStateTransitionGuardCheck < Test::Unit::TestCase
53
53
  st.executable?(obj, *args)
54
54
  end
55
55
 
56
- test "should call the method on the object if guard is a symbol" do
57
- opts = {:from => "foo", :to => "bar", :guard => [:test_guard, :test_another_guard] }
56
+ test 'should call the method on the object if guard is a symbol' do
57
+ opts = { from: 'foo', to: 'bar', guard: [:test_guard, :test_another_guard] }
58
58
  st = Transitions::StateTransition.new(opts)
59
59
 
60
60
  obj = stub
@@ -63,5 +63,4 @@ class TestStateTransitionGuardCheck < Test::Unit::TestCase
63
63
 
64
64
  assert st.executable?(obj, *args)
65
65
  end
66
-
67
66
  end
@@ -14,16 +14,16 @@ class Truck
14
14
  state :driving
15
15
 
16
16
  event :turn_key do
17
- transitions :from => :parked, :to => :running, :on_transition => :start_engine
17
+ transitions from: :parked, to: :running, on_transition: :start_engine
18
18
  end
19
19
 
20
20
  event :start_driving do
21
- transitions :from => :parked, :to => :driving, :on_transition => [:start_engine, :loosen_handbrake, :push_gas_pedal]
21
+ transitions from: :parked, to: :driving, on_transition: [:start_engine, :loosen_handbrake, :push_gas_pedal]
22
22
  end
23
23
  end
24
24
 
25
- %w!start_engine loosen_handbrake push_gas_pedal!.each do |m|
26
- define_method(m){ @test_recorder << m }
25
+ %w(start_engine loosen_handbrake push_gas_pedal).each do |m|
26
+ define_method(m) { @test_recorder << m }
27
27
  end
28
28
  end
29
29
 
@@ -14,17 +14,17 @@ class DrivingSchoolCar
14
14
  state :driving
15
15
  state :switched_off
16
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]
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
19
  end
20
20
 
21
21
  event :switch_off_engine do
22
- transitions :from => :parked, :to => :switched_off
22
+ transitions from: :parked, to: :switched_off
23
23
  end
24
24
  end
25
25
 
26
- %w!start_engine loosen_handbrake push_gas_pedal!.each do |m|
27
- define_method(m){}
26
+ %w(start_engine loosen_handbrake push_gas_pedal).each do |m|
27
+ define_method(m) {}
28
28
  end
29
29
  end
30
30
 
@@ -33,17 +33,17 @@ class TestStateTransitionSuccessCallback < Test::Unit::TestCase
33
33
  @car = DrivingSchoolCar.new
34
34
  end
35
35
 
36
- test "should execute the success callback after successfull event execution" do
36
+ test 'should execute the success callback after successfull event execution' do
37
37
  DrivingInstructor.expects(:applause!)
38
38
 
39
39
  @car.start_driving!
40
40
  end
41
41
 
42
- test "should not execute the success callback after event execution failed" do
42
+ test 'should not execute the success callback after event execution failed' do
43
43
  DrivingInstructor.expects(:applause!).never
44
44
 
45
45
  @car.stubs(:event_failed)
46
- @car.expects(:loosen_handbrake).raises("Drive with handbrake fail!")
46
+ @car.expects(:loosen_handbrake).raises('Drive with handbrake fail!')
47
47
  @car.start_driving!
48
48
  end
49
49
  end
data/transitions.gemspec CHANGED
@@ -1,29 +1,29 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path("../lib/transitions/version", __FILE__)
2
+ require File.expand_path('../lib/transitions/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
- s.name = "transitions"
5
+ s.name = 'transitions'
6
6
  s.version = Transitions::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
- s.authors = ["Jakub Kuzma", "Timo Roessner"]
9
- s.email = "timo.roessner@googlemail.com"
10
- s.homepage = "http://github.com/troessner/transitions"
11
- s.summary = "State machine extracted from ActiveModel"
12
- s.description = "Lightweight state machine extracted from ActiveModel"
8
+ s.authors = ['Jakub Kuzma', 'Timo Roessner']
9
+ s.email = 'timo.roessner@googlemail.com'
10
+ s.homepage = 'http://github.com/troessner/transitions'
11
+ s.summary = 'State machine extracted from ActiveModel'
12
+ s.description = 'Lightweight state machine extracted from ActiveModel'
13
13
 
14
- s.required_rubygems_version = ">= 1.3.6"
15
- s.rubyforge_project = "transitions"
14
+ s.required_rubygems_version = '>= 1.3.6'
15
+ s.rubyforge_project = 'transitions'
16
16
 
17
- s.add_development_dependency "bundler", "~> 1"
18
- s.add_development_dependency "test-unit", "~> 2.5"
19
- s.add_development_dependency "mocha", '~> 0.11.0' # With mocha 0.12 we get: undefined method `run' for #<StateMachineMachineTest:0x94918b8> (NoMethodError)
20
- s.add_development_dependency "rake"
21
- s.add_development_dependency "random_data"
17
+ s.add_development_dependency 'bundler', '~> 1'
18
+ s.add_development_dependency 'test-unit', '~> 2.5'
19
+ s.add_development_dependency 'mocha', '~> 0.11.0' # With mocha 0.12 we get: undefined method `run' for #<StateMachineMachineTest:0x94918b8> (NoMethodError)
20
+ s.add_development_dependency 'rake'
21
+ s.add_development_dependency 'random_data'
22
22
  s.add_development_dependency 'appraisal'
23
- s.add_development_dependency "activerecord", [">= 3.0", "<= 4.0"]
23
+ s.add_development_dependency 'activerecord', ['>= 3.0', '<= 4.0']
24
24
 
25
25
  s.files = `git ls-files`.split("\n")
26
- s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
26
+ s.executables = `git ls-files`.split("\n").map { |f| f =~ /^bin\/(.*)/ ? Regexp.last_match[1] : nil }.compact
27
27
  s.require_path = 'lib'
28
28
  s.license = 'MIT'
29
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transitions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Kuzma
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-06 00:00:00.000000000 Z
12
+ date: 2015-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -122,6 +122,7 @@ extensions: []
122
122
  extra_rdoc_files: []
123
123
  files:
124
124
  - ".gitignore"
125
+ - ".rubocop.yml"
125
126
  - ".ruby-gemset"
126
127
  - ".ruby-version"
127
128
  - ".travis.yml"
@@ -186,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
187
  version: 1.3.6
187
188
  requirements: []
188
189
  rubyforge_project: transitions
189
- rubygems_version: 2.2.2
190
+ rubygems_version: 2.4.5
190
191
  signing_key:
191
192
  specification_version: 4
192
193
  summary: State machine extracted from ActiveModel