aasm 3.0.24 → 3.4.0

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -0
  3. data/.travis.yml +29 -4
  4. data/CHANGELOG.md +56 -0
  5. data/Gemfile +10 -1
  6. data/LICENSE +1 -1
  7. data/README.md +151 -20
  8. data/aasm.gemspec +5 -6
  9. data/gemfiles/rails_3.2.gemfile +13 -0
  10. data/gemfiles/rails_4.0.gemfile +16 -0
  11. data/gemfiles/rails_4.1.gemfile +16 -0
  12. data/lib/aasm/aasm.rb +36 -32
  13. data/lib/aasm/base.rb +49 -31
  14. data/lib/aasm/event.rb +28 -17
  15. data/lib/aasm/instance_base.rb +9 -4
  16. data/lib/aasm/localizer.rb +1 -1
  17. data/lib/aasm/persistence/active_record_persistence.rb +65 -16
  18. data/lib/aasm/persistence/base.rb +10 -14
  19. data/lib/aasm/persistence/mongoid_persistence.rb +10 -8
  20. data/lib/aasm/persistence/sequel_persistence.rb +108 -0
  21. data/lib/aasm/persistence.rb +3 -0
  22. data/lib/aasm/state.rb +4 -3
  23. data/lib/aasm/state_machine.rb +18 -10
  24. data/lib/aasm/transition.rb +13 -6
  25. data/lib/aasm/version.rb +1 -1
  26. data/lib/aasm.rb +0 -3
  27. data/spec/database.rb +33 -0
  28. data/spec/models/double_definer.rb +21 -0
  29. data/spec/models/foo.rb +2 -1
  30. data/spec/models/guardian.rb +48 -0
  31. data/spec/models/mongoid/no_scope_mongoid.rb +1 -1
  32. data/spec/models/mongoid/simple_mongoid.rb +5 -4
  33. data/spec/models/mongoid/simple_new_dsl_mongoid.rb +1 -1
  34. data/spec/models/not_auto_loaded/process.rb +10 -8
  35. data/spec/models/persistence.rb +5 -13
  36. data/spec/spec_helper.rb +1 -1
  37. data/spec/unit/api_spec.rb +12 -12
  38. data/spec/unit/callbacks_spec.rb +29 -45
  39. data/spec/unit/complex_example_spec.rb +24 -15
  40. data/spec/unit/event_naming_spec.rb +24 -0
  41. data/spec/unit/event_spec.rb +124 -76
  42. data/spec/unit/guard_spec.rb +60 -0
  43. data/spec/unit/initial_state_spec.rb +4 -5
  44. data/spec/unit/inspection_spec.rb +42 -53
  45. data/spec/unit/localizer_spec.rb +22 -18
  46. data/spec/unit/memory_leak_spec.rb +2 -2
  47. data/spec/unit/new_dsl_spec.rb +2 -2
  48. data/spec/unit/persistence/active_record_persistence_spec.rb +357 -89
  49. data/spec/unit/persistence/mongoid_persistance_spec.rb +102 -81
  50. data/spec/unit/persistence/sequel_persistence_spec.rb +103 -0
  51. data/spec/unit/reloading_spec.rb +15 -0
  52. data/spec/unit/simple_example_spec.rb +20 -21
  53. data/spec/unit/state_spec.rb +16 -16
  54. data/spec/unit/subclassing_spec.rb +8 -8
  55. data/spec/unit/transition_spec.rb +59 -44
  56. metadata +38 -96
  57. data/lib/aasm/deprecated/aasm.rb +0 -15
  58. data/spec/models/callback_old_dsl.rb +0 -41
  59. data/spec/schema.rb +0 -35
@@ -1,131 +1,152 @@
1
1
  describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version.create('1.9.3') do
2
2
  # describe 'mongoid' do
3
3
 
4
- before(:all) do
4
+ begin
5
5
  require 'mongoid'
6
6
  require 'logger'
7
7
  require 'spec_helper'
8
- Dir[File.dirname(__FILE__) + "/../../models/mongoid/*.rb"].sort.each { |f| require File.expand_path(f) }
9
8
 
10
- # if you want to see the statements while running the spec enable the following line
11
- # Mongoid.logger = Logger.new(STDERR)
9
+ before(:all) do
10
+ Dir[File.dirname(__FILE__) + "/../../models/mongoid/*.rb"].sort.each { |f| require File.expand_path(f) }
12
11
 
13
- DATABASE_NAME = "mongoid_#{Process.pid}"
12
+ # if you want to see the statements while running the spec enable the following line
13
+ # Mongoid.logger = Logger.new(STDERR)
14
14
 
15
- Mongoid.configure do |config|
16
- config.connect_to DATABASE_NAME
15
+ DATABASE_NAME = "mongoid_#{Process.pid}"
16
+
17
+ Mongoid.configure do |config|
18
+ config.connect_to DATABASE_NAME
19
+ end
17
20
  end
18
- end
19
21
 
20
- after do
21
- Mongoid.purge!
22
- end
22
+ after do
23
+ Mongoid.purge!
24
+ end
23
25
 
24
- describe "named scopes with the old DSL" do
26
+ describe "named scopes with the old DSL" do
25
27
 
26
- context "Does not already respond_to? the scope name" do
27
- it "should add a scope" do
28
- SimpleMongoid.should respond_to(:unknown_scope)
29
- SimpleMongoid.unknown_scope.class.should == Mongoid::Criteria
28
+ context "Does not already respond_to? the scope name" do
29
+ it "should add a scope" do
30
+ expect(SimpleMongoid).to respond_to(:unknown_scope)
31
+ expect(SimpleMongoid.unknown_scope.class).to eq(Mongoid::Criteria)
32
+ end
30
33
  end
31
- end
32
34
 
33
- context "Already respond_to? the scope name" do
34
- it "should not add a scope" do
35
- SimpleMongoid.should respond_to(:new)
36
- SimpleMongoid.new.class.should == SimpleMongoid
35
+ context "Already respond_to? the scope name" do
36
+ it "should not add a scope" do
37
+ expect(SimpleMongoid).to respond_to(:new)
38
+ expect(SimpleMongoid.new.class).to eq(SimpleMongoid)
39
+ end
37
40
  end
41
+
38
42
  end
39
43
 
40
- end
44
+ describe "named scopes with the new DSL" do
41
45
 
42
- describe "named scopes with the new DSL" do
46
+ context "Does not already respond_to? the scope name" do
47
+ it "should add a scope" do
48
+ expect(SimpleNewDslMongoid).to respond_to(:unknown_scope)
49
+ expect(SimpleNewDslMongoid.unknown_scope.class).to eq(Mongoid::Criteria)
50
+ end
51
+ end
43
52
 
44
- context "Does not already respond_to? the scope name" do
45
- it "should add a scope" do
46
- SimpleNewDslMongoid.should respond_to(:unknown_scope)
47
- SimpleNewDslMongoid.unknown_scope.class.should == Mongoid::Criteria
53
+ context "Already respond_to? the scope name" do
54
+ it "should not add a scope" do
55
+ expect(SimpleNewDslMongoid).to respond_to(:new)
56
+ expect(SimpleNewDslMongoid.new.class).to eq(SimpleNewDslMongoid)
57
+ end
48
58
  end
49
- end
50
59
 
51
- context "Already respond_to? the scope name" do
52
- it "should not add a scope" do
53
- SimpleNewDslMongoid.should respond_to(:new)
54
- SimpleNewDslMongoid.new.class.should == SimpleNewDslMongoid
60
+ it "does not create scopes if requested" do
61
+ expect(NoScopeMongoid).not_to respond_to(:ignored_scope)
55
62
  end
56
- end
57
63
 
58
- it "does not create scopes if requested" do
59
- NoScopeMongoid.should_not respond_to(:ignored_scope)
60
64
  end
61
65
 
62
- end
66
+ describe "#find_in_state" do
63
67
 
64
- describe "#find_in_state" do
68
+ let!(:model) { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
69
+ let!(:model_id) { model._id }
65
70
 
66
- let!(:model) { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
67
- let!(:model_id) { model._id }
71
+ it "should respond to method" do
72
+ expect(SimpleNewDslMongoid).to respond_to(:find_in_state)
73
+ end
68
74
 
69
- it "should respond to method" do
70
- SimpleNewDslMongoid.should respond_to(:find_in_state)
71
- end
75
+ it "should find the model when given the correct scope and model id" do
76
+ expect(SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope').class).to eq(SimpleNewDslMongoid)
77
+ expect(SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope')).to eq(model)
78
+ end
72
79
 
73
- it "should find the model when given the correct scope and model id" do
74
- SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope').class.should == SimpleNewDslMongoid
75
- SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope').should == model
76
- end
80
+ it "should raise DocumentNotFound error when given incorrect scope" do
81
+ expect {SimpleNewDslMongoid.find_in_state(model_id, 'new')}.to raise_error Mongoid::Errors::DocumentNotFound
82
+ end
77
83
 
78
- it "should raise DocumentNotFound error when given incorrect scope" do
79
- expect {SimpleNewDslMongoid.find_in_state(model_id, 'new')}.to raise_error Mongoid::Errors::DocumentNotFound
80
- end
84
+ it "should raise DocumentNotFound error when given incorrect model id" do
85
+ expect {SimpleNewDslMongoid.find_in_state('bad_id', 'unknown_scope')}.to raise_error Mongoid::Errors::DocumentNotFound
86
+ end
81
87
 
82
- it "should raise DocumentNotFound error when given incorrect model id" do
83
- expect {SimpleNewDslMongoid.find_in_state('bad_id', 'unknown_scope')}.to raise_error Mongoid::Errors::DocumentNotFound
84
88
  end
85
89
 
86
- end
90
+ describe "#count_in_state" do
87
91
 
88
- describe "#count_in_state" do
92
+ before do
93
+ 3.times { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
94
+ end
89
95
 
90
- before do
91
- 3.times { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
92
- end
96
+ it "should respond to method" do
97
+ expect(SimpleNewDslMongoid).to respond_to(:count_in_state)
98
+ end
93
99
 
94
- it "should respond to method" do
95
- SimpleNewDslMongoid.should respond_to(:count_in_state)
96
- end
100
+ it "should return n for a scope with n records persisted" do
101
+ expect(SimpleNewDslMongoid.count_in_state('unknown_scope').class).to eq(Fixnum)
102
+ expect(SimpleNewDslMongoid.count_in_state('unknown_scope')).to eq(3)
103
+ end
97
104
 
98
- it "should return n for a scope with n records persisted" do
99
- SimpleNewDslMongoid.count_in_state('unknown_scope').class.should == Fixnum
100
- SimpleNewDslMongoid.count_in_state('unknown_scope').should == 3
101
- end
105
+ it "should return zero for a scope without records persisted" do
106
+ expect(SimpleNewDslMongoid.count_in_state('new').class).to eq(Fixnum)
107
+ expect(SimpleNewDslMongoid.count_in_state('new')).to eq(0)
108
+ end
102
109
 
103
- it "should return zero for a scope without records persisted" do
104
- SimpleNewDslMongoid.count_in_state('new').class.should == Fixnum
105
- SimpleNewDslMongoid.count_in_state('new').should == 0
106
110
  end
107
111
 
108
- end
112
+ describe "#with_state_scope" do
109
113
 
110
- describe "#with_state_scope" do
114
+ before do
115
+ 3.times { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
116
+ 2.times { SimpleNewDslMongoid.create!(:status => :new) }
117
+ end
111
118
 
112
- before do
113
- 3.times { SimpleNewDslMongoid.create!(:status => :unknown_scope) }
114
- 2.times { SimpleNewDslMongoid.create!(:status => :new) }
115
- end
119
+ it "should respond to method" do
120
+ expect(SimpleNewDslMongoid).to respond_to(:with_state_scope)
121
+ end
122
+
123
+ it "should correctly process block" do
124
+ expect(SimpleNewDslMongoid.with_state_scope('unknown_scope') do
125
+ SimpleNewDslMongoid.count
126
+ end).to eq(3)
127
+ expect(SimpleNewDslMongoid.with_state_scope('new') do
128
+ SimpleNewDslMongoid.count
129
+ end).to eq(2)
130
+ end
116
131
 
117
- it "should respond to method" do
118
- SimpleNewDslMongoid.should respond_to(:with_state_scope)
119
132
  end
120
133
 
121
- it "should correctly process block" do
122
- SimpleNewDslMongoid.with_state_scope('unknown_scope') do
123
- SimpleNewDslMongoid.count
124
- end.should == 3
125
- SimpleNewDslMongoid.with_state_scope('new') do
126
- SimpleNewDslMongoid.count
127
- end.should == 2
134
+
135
+ describe "instance methods" do
136
+ let(:simple) {SimpleNewDslMongoid.new}
137
+
138
+ it "should call aasm_ensure_initial_state on validation before create" do
139
+ expect(simple).to receive(:aasm_ensure_initial_state).and_return(true)
140
+ simple.valid?
141
+ end
142
+
143
+ it "should call aasm_ensure_initial_state before create, even if skipping validations" do
144
+ expect(simple).to receive(:aasm_ensure_initial_state).and_return(true)
145
+ simple.save(:validate => false)
146
+ end
128
147
  end
129
148
 
149
+ rescue LoadError
150
+ puts "Not running Mongoid specs because mongoid gem is not installed!!!"
130
151
  end
131
152
  end
@@ -0,0 +1,103 @@
1
+
2
+ describe 'sequel' do
3
+ begin
4
+ require 'sequel'
5
+ require 'logger'
6
+ require 'spec_helper'
7
+
8
+ before(:all) do
9
+ db = Sequel.sqlite
10
+ # if you want to see the statements while running the spec enable the following line
11
+ # db.loggers << Logger.new($stderr)
12
+ db.create_table(:models) do
13
+ primary_key :id
14
+ String :status
15
+ end
16
+
17
+ @model = Class.new(Sequel::Model(db)) do
18
+ set_dataset(:models)
19
+ attr_accessor :default
20
+ include AASM
21
+ aasm :column => :status
22
+ aasm do
23
+ state :alpha, :initial => true
24
+ state :beta
25
+ state :gamma
26
+ event :release do
27
+ transitions :from => [:alpha, :beta, :gamma], :to => :beta
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ describe "instance methods" do
34
+ let(:model) {@model.new}
35
+
36
+ it "should respond to aasm persistence methods" do
37
+ expect(model).to respond_to(:aasm_read_state)
38
+ expect(model).to respond_to(:aasm_write_state)
39
+ expect(model).to respond_to(:aasm_write_state_without_persistence)
40
+ end
41
+
42
+ it "should return the initial state when new and the aasm field is nil" do
43
+ expect(model.aasm.current_state).to eq(:alpha)
44
+ end
45
+
46
+ it "should return the aasm column when new and the aasm field is not nil" do
47
+ model.status = "beta"
48
+ expect(model.aasm.current_state).to eq(:beta)
49
+ end
50
+
51
+ it "should return the aasm column when not new and the aasm_column is not nil" do
52
+ allow(model).to receive(:new?).and_return(false)
53
+ model.status = "gamma"
54
+ expect(model.aasm.current_state).to eq(:gamma)
55
+ end
56
+
57
+ it "should allow a nil state" do
58
+ allow(model).to receive(:new?).and_return(false)
59
+ model.status = nil
60
+ expect(model.aasm.current_state).to be_nil
61
+ end
62
+
63
+ it "should call aasm_ensure_initial_state on validation before create" do
64
+ expect(model).to receive(:aasm_ensure_initial_state).and_return(true)
65
+ model.valid?
66
+ end
67
+
68
+ it "should call aasm_ensure_initial_state before create, even if skipping validations" do
69
+ expect(model).to receive(:aasm_ensure_initial_state).and_return(true)
70
+ model.save(:validate => false)
71
+ end
72
+ end
73
+
74
+ describe 'subclasses' do
75
+ it "should have the same states as its parent class" do
76
+ expect(Class.new(@model).aasm.states).to eq(@model.aasm.states)
77
+ end
78
+
79
+ it "should have the same events as its parent class" do
80
+ expect(Class.new(@model).aasm.events).to eq(@model.aasm.events)
81
+ end
82
+
83
+ it "should have the same column as its parent even for the new dsl" do
84
+ expect(@model.aasm_column).to eq(:status)
85
+ expect(Class.new(@model).aasm_column).to eq(:status)
86
+ end
87
+ end
88
+
89
+ describe 'initial states' do
90
+ it 'should support conditions' do
91
+ @model.aasm do
92
+ initial_state lambda{ |m| m.default }
93
+ end
94
+
95
+ expect(@model.new(:default => :beta).aasm.current_state).to eq(:beta)
96
+ expect(@model.new(:default => :gamma).aasm.current_state).to eq(:gamma)
97
+ end
98
+ end
99
+
100
+ rescue LoadError
101
+ puts "Not running Sequel specs because sequel gem is not installed!!!"
102
+ end
103
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'callbacks for the new DSL' do
4
+ let(:definer) { DoubleDefiner.new }
5
+
6
+ it "allows extending states" do
7
+ expect(definer).to receive(:do_enter)
8
+ definer.finish
9
+ end
10
+
11
+ it "allows extending events" do
12
+ expect(definer).to receive(:do_on_transition)
13
+ definer.finish
14
+ end
15
+ end
@@ -20,40 +20,39 @@ describe 'state machine' do
20
20
  let(:payment) {Payment.new}
21
21
 
22
22
  it 'starts with an initial state' do
23
- payment.aasm_current_state.should == :initialised
24
- # payment.aasm.current_state.should == :initialised # not yet supported
25
- payment.should respond_to(:initialised?)
26
- payment.should be_initialised
23
+ expect(payment.aasm.current_state).to eq(:initialised)
24
+ expect(payment).to respond_to(:initialised?)
25
+ expect(payment).to be_initialised
27
26
  end
28
27
 
29
28
  it 'allows transitions to other states' do
30
- payment.should respond_to(:fill_out)
31
- payment.should respond_to(:fill_out!)
29
+ expect(payment).to respond_to(:fill_out)
30
+ expect(payment).to respond_to(:fill_out!)
32
31
  payment.fill_out!
33
- payment.should respond_to(:filled_out?)
34
- payment.should be_filled_out
32
+ expect(payment).to respond_to(:filled_out?)
33
+ expect(payment).to be_filled_out
35
34
 
36
- payment.should respond_to(:authorise)
37
- payment.should respond_to(:authorise!)
35
+ expect(payment).to respond_to(:authorise)
36
+ expect(payment).to respond_to(:authorise!)
38
37
  payment.authorise
39
- payment.should respond_to(:authorised?)
40
- payment.should be_authorised
38
+ expect(payment).to respond_to(:authorised?)
39
+ expect(payment).to be_authorised
41
40
  end
42
41
 
43
42
  it 'denies transitions to other states' do
44
- lambda {payment.authorise}.should raise_error(AASM::InvalidTransition)
45
- lambda {payment.authorise!}.should raise_error(AASM::InvalidTransition)
43
+ expect {payment.authorise}.to raise_error(AASM::InvalidTransition)
44
+ expect {payment.authorise!}.to raise_error(AASM::InvalidTransition)
46
45
  payment.fill_out
47
- lambda {payment.fill_out}.should raise_error(AASM::InvalidTransition)
48
- lambda {payment.fill_out!}.should raise_error(AASM::InvalidTransition)
46
+ expect {payment.fill_out}.to raise_error(AASM::InvalidTransition)
47
+ expect {payment.fill_out!}.to raise_error(AASM::InvalidTransition)
49
48
  payment.authorise
50
- lambda {payment.fill_out}.should raise_error(AASM::InvalidTransition)
51
- lambda {payment.fill_out!}.should raise_error(AASM::InvalidTransition)
49
+ expect {payment.fill_out}.to raise_error(AASM::InvalidTransition)
50
+ expect {payment.fill_out!}.to raise_error(AASM::InvalidTransition)
52
51
  end
53
52
 
54
53
  it 'defines constants for each state name' do
55
- Payment::STATE_INITIALISED.should eq(:initialised)
56
- Payment::STATE_FILLED_OUT.should eq(:filled_out)
57
- Payment::STATE_AUTHORISED.should eq(:authorised)
54
+ expect(Payment::STATE_INITIALISED).to eq(:initialised)
55
+ expect(Payment::STATE_FILLED_OUT).to eq(:filled_out)
56
+ expect(Payment::STATE_AUTHORISED).to eq(:authorised)
58
57
  end
59
58
  end
@@ -12,34 +12,34 @@ describe AASM::State do
12
12
 
13
13
  it 'should set the name' do
14
14
  state = new_state
15
- state.name.should == :astate
15
+ expect(state.name).to eq(:astate)
16
16
  end
17
17
 
18
18
  it 'should set the display_name from name' do
19
- new_state.display_name.should == 'Astate'
19
+ expect(new_state.display_name).to eq('Astate')
20
20
  end
21
21
 
22
22
  it 'should set the display_name from options' do
23
- new_state(:display => "A State").display_name.should == 'A State'
23
+ expect(new_state(:display => "A State").display_name).to eq('A State')
24
24
  end
25
25
 
26
26
  it 'should set the options and expose them as options' do
27
- new_state.options.should == @options
27
+ expect(new_state.options).to eq(@options)
28
28
  end
29
29
 
30
30
  it 'should be equal to a symbol of the same name' do
31
- new_state.should == :astate
31
+ expect(new_state).to eq(:astate)
32
32
  end
33
33
 
34
34
  it 'should be equal to a State of the same name' do
35
- new_state.should == new_state
35
+ expect(new_state).to eq(new_state)
36
36
  end
37
37
 
38
38
  it 'should send a message to the record for an action if the action is present as a symbol' do
39
39
  state = new_state(:entering => :foo)
40
40
 
41
41
  record = double('record')
42
- record.should_receive(:foo)
42
+ expect(record).to receive(:foo)
43
43
 
44
44
  state.fire_callbacks(:entering, record)
45
45
  end
@@ -48,7 +48,7 @@ describe AASM::State do
48
48
  state = new_state(:entering => 'foo')
49
49
 
50
50
  record = double('record')
51
- record.should_receive(:foo)
51
+ expect(record).to receive(:foo)
52
52
 
53
53
  state.fire_callbacks(:entering, record)
54
54
  end
@@ -57,10 +57,10 @@ describe AASM::State do
57
57
  state = new_state(:entering => [:a, :b, "c", lambda {|r| r.foobar }])
58
58
 
59
59
  record = double('record')
60
- record.should_receive(:a)
61
- record.should_receive(:b)
62
- record.should_receive(:c)
63
- record.should_receive(:foobar)
60
+ expect(record).to receive(:a)
61
+ expect(record).to receive(:b)
62
+ expect(record).to receive(:c)
63
+ expect(record).to receive(:foobar)
64
64
 
65
65
  state.fire_callbacks(:entering, record)
66
66
  end
@@ -69,9 +69,9 @@ describe AASM::State do
69
69
  state = new_state(:entering => [:a, :b, :c])
70
70
 
71
71
  record = double('record')
72
- record.should_receive(:a)
73
- record.should_receive(:b).and_throw(:halt_aasm_chain)
74
- record.should_not_receive(:c)
72
+ expect(record).to receive(:a)
73
+ expect(record).to receive(:b).and_throw(:halt_aasm_chain)
74
+ expect(record).not_to receive(:c)
75
75
 
76
76
  state.fire_callbacks(:entering, record)
77
77
  end
@@ -80,7 +80,7 @@ describe AASM::State do
80
80
  state = new_state(:entering => Proc.new {|r| r.foobar})
81
81
 
82
82
  record = double('record')
83
- record.should_receive(:foobar)
83
+ expect(record).to receive(:foobar)
84
84
 
85
85
  state.fire_callbacks(:entering, record)
86
86
  end
@@ -4,28 +4,28 @@ describe 'subclassing' do
4
4
  let(:son) {Son.new}
5
5
 
6
6
  it 'should have the parent states' do
7
- Foo.aasm_states.each do |state|
8
- FooTwo.aasm_states.should include(state)
7
+ Foo.aasm.states.each do |state|
8
+ expect(FooTwo.aasm.states).to include(state)
9
9
  end
10
- Baz.aasm_states.should == Bar.aasm_states
10
+ expect(Baz.aasm.states).to eq(Bar.aasm.states)
11
11
  end
12
12
 
13
13
  it 'should not add the child states to the parent machine' do
14
- Foo.aasm_states.should_not include(:foo)
14
+ expect(Foo.aasm.states).not_to include(:foo)
15
15
  end
16
16
 
17
17
  it "should have the same events as its parent" do
18
- Baz.aasm_events.should == Bar.aasm_events
18
+ expect(Baz.aasm.events).to eq(Bar.aasm.events)
19
19
  end
20
20
 
21
21
  it 'should know how to respond to `may_add_details?`' do
22
- son.may_add_details?.should be_true
22
+ expect(son.may_add_details?).to be_true
23
23
  end
24
24
 
25
25
  it 'should not break if I call Son#update_state' do
26
26
  son.update_state
27
- son.aasm_current_state.should == :pending_details_confirmation
27
+ expect(son.aasm.current_state).to eq(:pending_details_confirmation)
28
28
  end
29
-
29
+
30
30
  end
31
31