aasm 3.0.25 → 3.1.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.
@@ -30,11 +30,15 @@ describe 'localized state names' do
30
30
  end
31
31
 
32
32
  it 'should localize' do
33
- LocalizerTestModel.aasm.states.detect {|s| s == :opened}.localized_name.should == "It's open now!"
33
+ state = LocalizerTestModel.aasm.states.detect {|s| s == :opened}
34
+ expect(state.localized_name).to eq("It's open now!")
35
+ expect(state.human_name).to eq("It's open now!")
34
36
  end
35
37
 
36
38
  it 'should use fallback' do
37
- LocalizerTestModel.aasm.states.detect {|s| s == :closed}.localized_name.should == 'Closed'
39
+ state = LocalizerTestModel.aasm.states.detect {|s| s == :closed}
40
+ expect(state.localized_name).to eq('Closed')
41
+ expect(state.human_name).to eq('Closed')
38
42
  end
39
43
  end
40
44
 
@@ -54,21 +58,21 @@ describe AASM::Localizer, "new style" do
54
58
 
55
59
  context 'aasm.human_state' do
56
60
  it 'should return translated state value' do
57
- foo_opened.aasm.human_state.should == "It's open now!"
61
+ expect(foo_opened.aasm.human_state).to eq("It's open now!")
58
62
  end
59
63
 
60
64
  it 'should return humanized value if not localized' do
61
- foo_closed.aasm.human_state.should == "Closed"
65
+ expect(foo_closed.aasm.human_state).to eq("Closed")
62
66
  end
63
67
  end
64
68
 
65
69
  context 'aasm_human_event_name' do
66
70
  it 'should return translated event name' do
67
- LocalizerTestModel.aasm_human_event_name(:close).should == "Let's close it!"
71
+ expect(LocalizerTestModel.aasm_human_event_name(:close)).to eq("Let's close it!")
68
72
  end
69
73
 
70
74
  it 'should return humanized event name' do
71
- LocalizerTestModel.aasm_human_event_name(:open).should == "Open"
75
+ expect(LocalizerTestModel.aasm_human_event_name(:open)).to eq("Open")
72
76
  end
73
77
  end
74
78
  end
@@ -89,21 +93,21 @@ describe AASM::Localizer, "deprecated style" do
89
93
 
90
94
  context 'aasm.human_state' do
91
95
  it 'should return translated state value' do
92
- foo_opened.aasm.human_state.should == "It's open now!"
96
+ expect(foo_opened.aasm.human_state).to eq("It's open now!")
93
97
  end
94
98
 
95
99
  it 'should return humanized value if not localized' do
96
- foo_closed.aasm.human_state.should == "Closed"
100
+ expect(foo_closed.aasm.human_state).to eq("Closed")
97
101
  end
98
102
  end
99
103
 
100
104
  context 'aasm_human_event_name' do
101
105
  it 'should return translated event name' do
102
- LocalizerTestModel.aasm_human_event_name(:close).should == "Let's close it!"
106
+ expect(LocalizerTestModel.aasm_human_event_name(:close)).to eq("Let's close it!")
103
107
  end
104
108
 
105
109
  it 'should return humanized event name' do
106
- LocalizerTestModel.aasm_human_event_name(:open).should == "Open"
110
+ expect(LocalizerTestModel.aasm_human_event_name(:open)).to eq("Open")
107
111
  end
108
112
  end
109
113
  end
@@ -5,8 +5,8 @@ describe "the new dsl" do
5
5
  let(:process) {ProcessWithNewDsl.new}
6
6
 
7
7
  it 'should not conflict with other event or state methods' do
8
- lambda {ProcessWithNewDsl.state}.should raise_error(RuntimeError, "wrong state method")
9
- lambda {ProcessWithNewDsl.event}.should raise_error(RuntimeError, "wrong event method")
8
+ expect {ProcessWithNewDsl.state}.to raise_error(RuntimeError, "wrong state method")
9
+ expect {ProcessWithNewDsl.event}.to raise_error(RuntimeError, "wrong event method")
10
10
  end
11
11
 
12
12
  end
@@ -9,8 +9,8 @@ load_schema
9
9
 
10
10
  shared_examples_for "aasm model" do
11
11
  it "should include persistence mixins" do
12
- klass.included_modules.should be_include(AASM::Persistence::ActiveRecordPersistence)
13
- klass.included_modules.should be_include(AASM::Persistence::ActiveRecordPersistence::InstanceMethods)
12
+ expect(klass.included_modules).to be_include(AASM::Persistence::ActiveRecordPersistence)
13
+ expect(klass.included_modules).to be_include(AASM::Persistence::ActiveRecordPersistence::InstanceMethods)
14
14
  end
15
15
  end
16
16
 
@@ -18,45 +18,45 @@ describe "instance methods" do
18
18
  let(:gate) {Gate.new}
19
19
 
20
20
  it "should respond to aasm persistence methods" do
21
- gate.should respond_to(:aasm_read_state)
22
- gate.should respond_to(:aasm_write_state)
23
- gate.should respond_to(:aasm_write_state_without_persistence)
21
+ expect(gate).to respond_to(:aasm_read_state)
22
+ expect(gate).to respond_to(:aasm_write_state)
23
+ expect(gate).to respond_to(:aasm_write_state_without_persistence)
24
24
  end
25
25
 
26
26
  it "should return the initial state when new and the aasm field is nil" do
27
- gate.aasm.current_state.should == :opened
27
+ expect(gate.aasm.current_state).to eq(:opened)
28
28
  end
29
29
 
30
30
  it "should return the aasm column when new and the aasm field is not nil" do
31
31
  gate.aasm_state = "closed"
32
- gate.aasm.current_state.should == :closed
32
+ expect(gate.aasm.current_state).to eq(:closed)
33
33
  end
34
34
 
35
35
  it "should return the aasm column when not new and the aasm_column is not nil" do
36
- gate.stub(:new_record?).and_return(false)
36
+ allow(gate).to receive(:new_record?).and_return(false)
37
37
  gate.aasm_state = "state"
38
- gate.aasm.current_state.should == :state
38
+ expect(gate.aasm.current_state).to eq(:state)
39
39
  end
40
40
 
41
41
  it "should allow a nil state" do
42
- gate.stub(:new_record?).and_return(false)
42
+ allow(gate).to receive(:new_record?).and_return(false)
43
43
  gate.aasm_state = nil
44
- gate.aasm.current_state.should be_nil
44
+ expect(gate.aasm.current_state).to be_nil
45
45
  end
46
46
 
47
47
  it "should call aasm_ensure_initial_state on validation before create" do
48
- gate.should_receive(:aasm_ensure_initial_state).and_return(true)
48
+ expect(gate).to receive(:aasm_ensure_initial_state).and_return(true)
49
49
  gate.valid?
50
50
  end
51
51
 
52
52
  it "should call aasm_ensure_initial_state before create, even if skipping validations" do
53
- gate.should_receive(:aasm_ensure_initial_state).and_return(true)
53
+ expect(gate).to receive(:aasm_ensure_initial_state).and_return(true)
54
54
  gate.save(:validate => false)
55
55
  end
56
56
 
57
57
  it "should not call aasm_ensure_initial_state on validation before update" do
58
- gate.stub(:new_record?).and_return(false)
59
- gate.should_not_receive(:aasm_ensure_initial_state)
58
+ allow(gate).to receive(:new_record?).and_return(false)
59
+ expect(gate).not_to receive(:aasm_ensure_initial_state)
60
60
  gate.valid?
61
61
  end
62
62
 
@@ -64,36 +64,36 @@ end
64
64
 
65
65
  describe 'subclasses' do
66
66
  it "should have the same states as its parent class" do
67
- DerivateNewDsl.aasm.states.should == SimpleNewDsl.aasm.states
67
+ expect(DerivateNewDsl.aasm.states).to eq(SimpleNewDsl.aasm.states)
68
68
  end
69
69
 
70
70
  it "should have the same events as its parent class" do
71
- DerivateNewDsl.aasm.events.should == SimpleNewDsl.aasm.events
71
+ expect(DerivateNewDsl.aasm.events).to eq(SimpleNewDsl.aasm.events)
72
72
  end
73
73
 
74
74
  it "should have the same column as its parent even for the new dsl" do
75
- SimpleNewDsl.aasm_column.should == :status
76
- DerivateNewDsl.aasm_column.should == :status
75
+ expect(SimpleNewDsl.aasm_column).to eq(:status)
76
+ expect(DerivateNewDsl.aasm_column).to eq(:status)
77
77
  end
78
78
  end
79
79
 
80
80
  describe "named scopes with the new DSL" do
81
81
  context "Does not already respond_to? the scope name" do
82
82
  it "should add a scope" do
83
- SimpleNewDsl.should respond_to(:unknown_scope)
84
- SimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation).should be_true
83
+ expect(SimpleNewDsl).to respond_to(:unknown_scope)
84
+ expect(SimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation)).to be_true
85
85
  end
86
86
  end
87
87
 
88
88
  context "Already respond_to? the scope name" do
89
89
  it "should not add a scope" do
90
- SimpleNewDsl.should respond_to(:new)
91
- SimpleNewDsl.new.class.should == SimpleNewDsl
90
+ expect(SimpleNewDsl).to respond_to(:new)
91
+ expect(SimpleNewDsl.new.class).to eq(SimpleNewDsl)
92
92
  end
93
93
  end
94
94
 
95
95
  it "does not create scopes if requested" do
96
- NoScope.should_not respond_to(:ignored_scope)
96
+ expect(NoScope).not_to respond_to(:ignored_scope)
97
97
  end
98
98
 
99
99
  end
@@ -101,8 +101,8 @@ end
101
101
  describe 'initial states' do
102
102
 
103
103
  it 'should support conditions' do
104
- Thief.new(:skilled => true).aasm.current_state.should == :rich
105
- Thief.new(:skilled => false).aasm.current_state.should == :jailed
104
+ expect(Thief.new(:skilled => true).aasm.current_state).to eq(:rich)
105
+ expect(Thief.new(:skilled => false).aasm.current_state).to eq(:jailed)
106
106
  end
107
107
  end
108
108
 
@@ -110,54 +110,54 @@ describe 'transitions with persistence' do
110
110
 
111
111
  it "should work for valid models" do
112
112
  valid_object = Validator.create(:name => 'name')
113
- valid_object.should be_sleeping
113
+ expect(valid_object).to be_sleeping
114
114
  valid_object.status = :running
115
- valid_object.should be_running
115
+ expect(valid_object).to be_running
116
116
  end
117
117
 
118
118
  it 'should not store states for invalid models' do
119
119
  validator = Validator.create(:name => 'name')
120
- validator.should be_valid
121
- validator.should be_sleeping
120
+ expect(validator).to be_valid
121
+ expect(validator).to be_sleeping
122
122
 
123
123
  validator.name = nil
124
- validator.should_not be_valid
125
- validator.run!.should be_false
126
- validator.should be_sleeping
124
+ expect(validator).not_to be_valid
125
+ expect(validator.run!).to be_false
126
+ expect(validator).to be_sleeping
127
127
 
128
128
  validator.reload
129
- validator.should_not be_running
130
- validator.should be_sleeping
129
+ expect(validator).not_to be_running
130
+ expect(validator).to be_sleeping
131
131
 
132
132
  validator.name = 'another name'
133
- validator.should be_valid
134
- validator.run!.should be_true
135
- validator.should be_running
133
+ expect(validator).to be_valid
134
+ expect(validator.run!).to be_true
135
+ expect(validator).to be_running
136
136
 
137
137
  validator.reload
138
- validator.should be_running
139
- validator.should_not be_sleeping
138
+ expect(validator).to be_running
139
+ expect(validator).not_to be_sleeping
140
140
  end
141
141
 
142
142
  it 'should store states for invalid models if configured' do
143
143
  persistor = InvalidPersistor.create(:name => 'name')
144
- persistor.should be_valid
145
- persistor.should be_sleeping
144
+ expect(persistor).to be_valid
145
+ expect(persistor).to be_sleeping
146
146
 
147
147
  persistor.name = nil
148
- persistor.should_not be_valid
149
- persistor.run!.should be_true
150
- persistor.should be_running
148
+ expect(persistor).not_to be_valid
149
+ expect(persistor.run!).to be_true
150
+ expect(persistor).to be_running
151
151
 
152
152
  persistor = InvalidPersistor.find(persistor.id)
153
153
  persistor.valid?
154
- persistor.should be_valid
155
- persistor.should be_running
156
- persistor.should_not be_sleeping
154
+ expect(persistor).to be_valid
155
+ expect(persistor).to be_running
156
+ expect(persistor).not_to be_sleeping
157
157
 
158
158
  persistor.reload
159
- persistor.should be_running
160
- persistor.should_not be_sleeping
159
+ expect(persistor).to be_running
160
+ expect(persistor).not_to be_sleeping
161
161
  end
162
162
 
163
163
  describe 'transactions' do
@@ -165,41 +165,81 @@ describe 'transitions with persistence' do
165
165
  let(:transactor) { Transactor.create!(:name => 'transactor', :worker => worker) }
166
166
 
167
167
  it 'should rollback all changes' do
168
- transactor.should be_sleeping
169
- worker.status.should == 'sleeping'
168
+ expect(transactor).to be_sleeping
169
+ expect(worker.status).to eq('sleeping')
170
170
 
171
- lambda {transactor.run!}.should raise_error(StandardError, 'failed on purpose')
172
- transactor.should be_running
173
- worker.reload.status.should == 'sleeping'
171
+ expect {transactor.run!}.to raise_error(StandardError, 'failed on purpose')
172
+ expect(transactor).to be_running
173
+ expect(worker.reload.status).to eq('sleeping')
174
174
  end
175
175
 
176
- it "should rollback all changes in nested transaction" do
177
- transactor.should be_sleeping
178
- worker.status.should == 'sleeping'
176
+ context "nested transactions" do
177
+ it "should rollback all changes in nested transaction" do
178
+ expect(transactor).to be_sleeping
179
+ expect(worker.status).to eq('sleeping')
179
180
 
180
- Worker.transaction do
181
- lambda { transactor.run! }.should raise_error(StandardError, 'failed on purpose')
181
+ Worker.transaction do
182
+ expect { transactor.run! }.to raise_error(StandardError, 'failed on purpose')
183
+ end
184
+
185
+ expect(transactor).to be_running
186
+ expect(worker.reload.status).to eq('sleeping')
182
187
  end
183
188
 
184
- transactor.should be_running
185
- worker.reload.status.should == 'sleeping'
189
+ it "should only rollback changes in the main transaction not the nested one" do
190
+ # change configuration to not require new transaction
191
+ AASM::StateMachine[Transactor].config.requires_new_transaction = false
192
+
193
+ expect(transactor).to be_sleeping
194
+ expect(worker.status).to eq('sleeping')
195
+
196
+ Worker.transaction do
197
+ expect { transactor.run! }.to raise_error(StandardError, 'failed on purpose')
198
+ end
199
+
200
+ expect(transactor).to be_running
201
+ expect(worker.reload.status).to eq('running')
202
+ end
186
203
  end
187
204
 
188
205
  describe "after_commit callback" do
189
206
  it "should fire :after_commit if transaction was successful" do
190
207
  validator = Validator.create(:name => 'name')
191
- validator.should be_sleeping
208
+ expect(validator).to be_sleeping
192
209
  validator.run!
193
- validator.should be_running
194
- validator.name.should_not == "name"
210
+ expect(validator).to be_running
211
+ expect(validator.name).not_to eq("name")
195
212
  end
196
213
 
197
214
  it "should not fire :after_commit if transaction failed" do
198
215
  validator = Validator.create(:name => 'name')
199
- lambda { validator.fail! }.should raise_error(StandardError, 'failed on purpose')
200
- validator.name.should == "name"
216
+ expect { validator.fail! }.to raise_error(StandardError, 'failed on purpose')
217
+ expect(validator.name).to eq("name")
201
218
  end
202
219
 
203
220
  end
204
221
  end
205
222
  end
223
+
224
+ describe "invalid states with persistence" do
225
+
226
+ it "should not store states" do
227
+ validator = Validator.create(:name => 'name')
228
+ validator.status = 'invalid_state'
229
+ expect(validator.save).to be_false
230
+ expect {validator.save!}.to raise_error(ActiveRecord::RecordInvalid)
231
+
232
+ validator.reload
233
+ expect(validator).to be_sleeping
234
+ end
235
+
236
+ it "should store invalid states if configured" do
237
+ persistor = InvalidPersistor.create(:name => 'name')
238
+ persistor.status = 'invalid_state'
239
+ expect(persistor.save).to be_true
240
+
241
+ persistor.reload
242
+ expect(persistor.status).to eq('invalid_state')
243
+ end
244
+
245
+ end
@@ -27,15 +27,15 @@ describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version
27
27
 
28
28
  context "Does not already respond_to? the scope name" do
29
29
  it "should add a scope" do
30
- SimpleMongoid.should respond_to(:unknown_scope)
31
- SimpleMongoid.unknown_scope.class.should == Mongoid::Criteria
30
+ expect(SimpleMongoid).to respond_to(:unknown_scope)
31
+ expect(SimpleMongoid.unknown_scope.class).to eq(Mongoid::Criteria)
32
32
  end
33
33
  end
34
34
 
35
35
  context "Already respond_to? the scope name" do
36
36
  it "should not add a scope" do
37
- SimpleMongoid.should respond_to(:new)
38
- SimpleMongoid.new.class.should == SimpleMongoid
37
+ expect(SimpleMongoid).to respond_to(:new)
38
+ expect(SimpleMongoid.new.class).to eq(SimpleMongoid)
39
39
  end
40
40
  end
41
41
 
@@ -45,20 +45,20 @@ describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version
45
45
 
46
46
  context "Does not already respond_to? the scope name" do
47
47
  it "should add a scope" do
48
- SimpleNewDslMongoid.should respond_to(:unknown_scope)
49
- SimpleNewDslMongoid.unknown_scope.class.should == Mongoid::Criteria
48
+ expect(SimpleNewDslMongoid).to respond_to(:unknown_scope)
49
+ expect(SimpleNewDslMongoid.unknown_scope.class).to eq(Mongoid::Criteria)
50
50
  end
51
51
  end
52
52
 
53
53
  context "Already respond_to? the scope name" do
54
54
  it "should not add a scope" do
55
- SimpleNewDslMongoid.should respond_to(:new)
56
- SimpleNewDslMongoid.new.class.should == SimpleNewDslMongoid
55
+ expect(SimpleNewDslMongoid).to respond_to(:new)
56
+ expect(SimpleNewDslMongoid.new.class).to eq(SimpleNewDslMongoid)
57
57
  end
58
58
  end
59
59
 
60
60
  it "does not create scopes if requested" do
61
- NoScopeMongoid.should_not respond_to(:ignored_scope)
61
+ expect(NoScopeMongoid).not_to respond_to(:ignored_scope)
62
62
  end
63
63
 
64
64
  end
@@ -69,12 +69,12 @@ describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version
69
69
  let!(:model_id) { model._id }
70
70
 
71
71
  it "should respond to method" do
72
- SimpleNewDslMongoid.should respond_to(:find_in_state)
72
+ expect(SimpleNewDslMongoid).to respond_to(:find_in_state)
73
73
  end
74
74
 
75
75
  it "should find the model when given the correct scope and model id" do
76
- SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope').class.should == SimpleNewDslMongoid
77
- SimpleNewDslMongoid.find_in_state(model_id, 'unknown_scope').should == model
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
78
  end
79
79
 
80
80
  it "should raise DocumentNotFound error when given incorrect scope" do
@@ -94,17 +94,17 @@ describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version
94
94
  end
95
95
 
96
96
  it "should respond to method" do
97
- SimpleNewDslMongoid.should respond_to(:count_in_state)
97
+ expect(SimpleNewDslMongoid).to respond_to(:count_in_state)
98
98
  end
99
99
 
100
100
  it "should return n for a scope with n records persisted" do
101
- SimpleNewDslMongoid.count_in_state('unknown_scope').class.should == Fixnum
102
- SimpleNewDslMongoid.count_in_state('unknown_scope').should == 3
101
+ expect(SimpleNewDslMongoid.count_in_state('unknown_scope').class).to eq(Fixnum)
102
+ expect(SimpleNewDslMongoid.count_in_state('unknown_scope')).to eq(3)
103
103
  end
104
104
 
105
105
  it "should return zero for a scope without records persisted" do
106
- SimpleNewDslMongoid.count_in_state('new').class.should == Fixnum
107
- SimpleNewDslMongoid.count_in_state('new').should == 0
106
+ expect(SimpleNewDslMongoid.count_in_state('new').class).to eq(Fixnum)
107
+ expect(SimpleNewDslMongoid.count_in_state('new')).to eq(0)
108
108
  end
109
109
 
110
110
  end
@@ -117,16 +117,16 @@ describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version
117
117
  end
118
118
 
119
119
  it "should respond to method" do
120
- SimpleNewDslMongoid.should respond_to(:with_state_scope)
120
+ expect(SimpleNewDslMongoid).to respond_to(:with_state_scope)
121
121
  end
122
122
 
123
123
  it "should correctly process block" do
124
- SimpleNewDslMongoid.with_state_scope('unknown_scope') do
124
+ expect(SimpleNewDslMongoid.with_state_scope('unknown_scope') do
125
125
  SimpleNewDslMongoid.count
126
- end.should == 3
127
- SimpleNewDslMongoid.with_state_scope('new') do
126
+ end).to eq(3)
127
+ expect(SimpleNewDslMongoid.with_state_scope('new') do
128
128
  SimpleNewDslMongoid.count
129
- end.should == 2
129
+ end).to eq(2)
130
130
  end
131
131
 
132
132
  end
@@ -136,12 +136,12 @@ describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version
136
136
  let(:simple) {SimpleNewDslMongoid.new}
137
137
 
138
138
  it "should call aasm_ensure_initial_state on validation before create" do
139
- simple.should_receive(:aasm_ensure_initial_state).and_return(true)
139
+ expect(simple).to receive(:aasm_ensure_initial_state).and_return(true)
140
140
  simple.valid?
141
141
  end
142
142
 
143
143
  it "should call aasm_ensure_initial_state before create, even if skipping validations" do
144
- simple.should_receive(:aasm_ensure_initial_state).and_return(true)
144
+ expect(simple).to receive(:aasm_ensure_initial_state).and_return(true)
145
145
  simple.save(:validate => false)
146
146
  end
147
147
  end
@@ -20,39 +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.should respond_to(:initialised?)
25
- 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
26
26
  end
27
27
 
28
28
  it 'allows transitions to other states' do
29
- payment.should respond_to(:fill_out)
30
- payment.should respond_to(:fill_out!)
29
+ expect(payment).to respond_to(:fill_out)
30
+ expect(payment).to respond_to(:fill_out!)
31
31
  payment.fill_out!
32
- payment.should respond_to(:filled_out?)
33
- payment.should be_filled_out
32
+ expect(payment).to respond_to(:filled_out?)
33
+ expect(payment).to be_filled_out
34
34
 
35
- payment.should respond_to(:authorise)
36
- payment.should respond_to(:authorise!)
35
+ expect(payment).to respond_to(:authorise)
36
+ expect(payment).to respond_to(:authorise!)
37
37
  payment.authorise
38
- payment.should respond_to(:authorised?)
39
- payment.should be_authorised
38
+ expect(payment).to respond_to(:authorised?)
39
+ expect(payment).to be_authorised
40
40
  end
41
41
 
42
42
  it 'denies transitions to other states' do
43
- lambda {payment.authorise}.should raise_error(AASM::InvalidTransition)
44
- 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)
45
45
  payment.fill_out
46
- lambda {payment.fill_out}.should raise_error(AASM::InvalidTransition)
47
- 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)
48
48
  payment.authorise
49
- lambda {payment.fill_out}.should raise_error(AASM::InvalidTransition)
50
- 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)
51
51
  end
52
52
 
53
53
  it 'defines constants for each state name' do
54
- Payment::STATE_INITIALISED.should eq(:initialised)
55
- Payment::STATE_FILLED_OUT.should eq(:filled_out)
56
- 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)
57
57
  end
58
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