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.
@@ -5,26 +5,26 @@ describe 'subclassing' do
5
5
 
6
6
  it 'should have the parent states' do
7
7
  Foo.aasm.states.each do |state|
8
- FooTwo.aasm.states.should include(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
@@ -4,46 +4,46 @@ describe 'transitions' do
4
4
 
5
5
  it 'should raise an exception when whiny' do
6
6
  process = ProcessWithNewDsl.new
7
- lambda { process.stop! }.should raise_error(AASM::InvalidTransition)
8
- process.should be_sleeping
7
+ expect { process.stop! }.to raise_error(AASM::InvalidTransition)
8
+ expect(process).to be_sleeping
9
9
  end
10
10
 
11
11
  it 'should not raise an exception when not whiny' do
12
12
  silencer = Silencer.new
13
- silencer.smile!.should be_false
14
- silencer.should be_silent
13
+ expect(silencer.smile!).to be_false
14
+ expect(silencer).to be_silent
15
15
  end
16
16
 
17
17
  it 'should not raise an exception when superclass not whiny' do
18
18
  sub = SubClassing.new
19
- sub.smile!.should be_false
20
- sub.should be_silent
19
+ expect(sub.smile!).to be_false
20
+ expect(sub).to be_silent
21
21
  end
22
22
 
23
23
  it 'should not raise an exception when from is nil even if whiny' do
24
24
  silencer = Silencer.new
25
- silencer.smile_any!.should be_true
26
- silencer.should be_smiling
25
+ expect(silencer.smile_any!).to be_true
26
+ expect(silencer).to be_smiling
27
27
  end
28
28
 
29
29
  it 'should call the block when success' do
30
30
  silencer = Silencer.new
31
31
  success = false
32
- lambda {
32
+ expect {
33
33
  silencer.smile_any! do
34
34
  success = true
35
35
  end
36
- }.should change { success }.to(true)
36
+ }.to change { success }.to(true)
37
37
  end
38
38
 
39
39
  it 'should not call the block when failure' do
40
40
  silencer = Silencer.new
41
41
  success = false
42
- lambda {
42
+ expect {
43
43
  silencer.smile! do
44
44
  success = true
45
45
  end
46
- }.should_not change { success }.to(true)
46
+ }.not_to change { success }.to(true)
47
47
  end
48
48
 
49
49
  end
@@ -56,9 +56,9 @@ describe AASM::Transition do
56
56
  opts = {:from => 'foo', :to => 'bar', :guard => 'g'}
57
57
  st = AASM::Transition.new(opts)
58
58
 
59
- st.from.should == opts[:from]
60
- st.to.should == opts[:to]
61
- st.opts.should == opts
59
+ expect(st.from).to eq(opts[:from])
60
+ expect(st.to).to eq(opts[:to])
61
+ expect(st.opts).to eq(opts)
62
62
  end
63
63
 
64
64
  it 'should pass equality check if from and to are the same' do
@@ -66,10 +66,10 @@ describe AASM::Transition do
66
66
  st = AASM::Transition.new(opts)
67
67
 
68
68
  obj = double('object')
69
- obj.stub(:from).and_return(opts[:from])
70
- obj.stub(:to).and_return(opts[:to])
69
+ allow(obj).to receive(:from).and_return(opts[:from])
70
+ allow(obj).to receive(:to).and_return(opts[:to])
71
71
 
72
- st.should == obj
72
+ expect(st).to eq(obj)
73
73
  end
74
74
 
75
75
  it 'should fail equality check if from are not the same' do
@@ -77,10 +77,10 @@ describe AASM::Transition do
77
77
  st = AASM::Transition.new(opts)
78
78
 
79
79
  obj = double('object')
80
- obj.stub(:from).and_return('blah')
81
- obj.stub(:to).and_return(opts[:to])
80
+ allow(obj).to receive(:from).and_return('blah')
81
+ allow(obj).to receive(:to).and_return(opts[:to])
82
82
 
83
- st.should_not == obj
83
+ expect(st).not_to eq(obj)
84
84
  end
85
85
 
86
86
  it 'should fail equality check if to are not the same' do
@@ -88,10 +88,10 @@ describe AASM::Transition do
88
88
  st = AASM::Transition.new(opts)
89
89
 
90
90
  obj = double('object')
91
- obj.stub(:from).and_return(opts[:from])
92
- obj.stub(:to).and_return('blah')
91
+ allow(obj).to receive(:from).and_return(opts[:from])
92
+ allow(obj).to receive(:to).and_return('blah')
93
93
 
94
- st.should_not == obj
94
+ expect(st).not_to eq(obj)
95
95
  end
96
96
  end
97
97
 
@@ -100,7 +100,7 @@ describe AASM::Transition, '- when performing guard checks' do
100
100
  opts = {:from => 'foo', :to => 'bar'}
101
101
  st = AASM::Transition.new(opts)
102
102
 
103
- st.perform(nil).should be_true
103
+ expect(st.perform(nil)).to be_true
104
104
  end
105
105
 
106
106
  it 'should call the method on the object if guard is a symbol' do
@@ -108,7 +108,7 @@ describe AASM::Transition, '- when performing guard checks' do
108
108
  st = AASM::Transition.new(opts)
109
109
 
110
110
  obj = double('object')
111
- obj.should_receive(:test)
111
+ expect(obj).to receive(:test)
112
112
 
113
113
  st.perform(obj)
114
114
  end
@@ -118,7 +118,7 @@ describe AASM::Transition, '- when performing guard checks' do
118
118
  st = AASM::Transition.new(opts)
119
119
 
120
120
  obj = double('object')
121
- obj.should_receive(:test)
121
+ expect(obj).to receive(:test)
122
122
 
123
123
  st.perform(obj)
124
124
  end
@@ -128,7 +128,7 @@ describe AASM::Transition, '- when performing guard checks' do
128
128
  st = AASM::Transition.new(opts)
129
129
 
130
130
  obj = double('object')
131
- obj.should_receive(:test)
131
+ expect(obj).to receive(:test)
132
132
 
133
133
  st.perform(obj)
134
134
  end
@@ -139,9 +139,9 @@ describe AASM::Transition, '- when executing the transition with a Proc' do
139
139
  opts = {:from => 'foo', :to => 'bar', :on_transition => Proc.new {|o| o.test}}
140
140
  st = AASM::Transition.new(opts)
141
141
  args = {:arg1 => '1', :arg2 => '2'}
142
- obj = double('object')
142
+ obj = double('object', :aasm => 'aasm')
143
143
 
144
- opts[:on_transition].should_receive(:call).with(any_args)
144
+ expect(opts[:on_transition]).to receive(:call).with(any_args)
145
145
 
146
146
  st.execute(obj, args)
147
147
  end
@@ -150,9 +150,9 @@ describe AASM::Transition, '- when executing the transition with a Proc' do
150
150
  opts = {:from => 'foo', :to => 'bar', :on_transition => Proc.new {||}}
151
151
  st = AASM::Transition.new(opts)
152
152
  args = {:arg1 => '1', :arg2 => '2'}
153
- obj = double('object')
153
+ obj = double('object', :aasm => 'aasm')
154
154
 
155
- opts[:on_transition].should_receive(:call).with(no_args)
155
+ expect(opts[:on_transition]).to receive(:call).with(no_args)
156
156
 
157
157
  st.execute(obj, args)
158
158
  end
@@ -163,9 +163,9 @@ describe AASM::Transition, '- when executing the transition with an :on_transtio
163
163
  opts = {:from => 'foo', :to => 'bar', :on_transition => 'test'}
164
164
  st = AASM::Transition.new(opts)
165
165
  args = {:arg1 => '1', :arg2 => '2'}
166
- obj = double('object')
166
+ obj = double('object', :aasm => 'aasm')
167
167
 
168
- obj.should_receive(:test)
168
+ expect(obj).to receive(:test)
169
169
 
170
170
  st.execute(obj, args)
171
171
  end
@@ -174,9 +174,9 @@ describe AASM::Transition, '- when executing the transition with an :on_transtio
174
174
  opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
175
175
  st = AASM::Transition.new(opts)
176
176
  args = {:arg1 => '1', :arg2 => '2'}
177
- obj = double('object')
177
+ obj = double('object', :aasm => 'aasm')
178
178
 
179
- obj.should_receive(:test)
179
+ expect(obj).to receive(:test)
180
180
 
181
181
  st.execute(obj, args)
182
182
  end
@@ -185,7 +185,7 @@ describe AASM::Transition, '- when executing the transition with an :on_transtio
185
185
  opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
186
186
  st = AASM::Transition.new(opts)
187
187
  args = {:arg1 => '1', :arg2 => '2'}
188
- obj = double('object')
188
+ obj = double('object', :aasm => 'aasm')
189
189
 
190
190
  def obj.test(args)
191
191
  "arg1: #{args[:arg1]} arg2: #{args[:arg2]}"
@@ -193,14 +193,14 @@ describe AASM::Transition, '- when executing the transition with an :on_transtio
193
193
 
194
194
  return_value = st.execute(obj, args)
195
195
 
196
- return_value.should == 'arg1: 1 arg2: 2'
196
+ expect(return_value).to eq('arg1: 1 arg2: 2')
197
197
  end
198
198
 
199
199
  it 'should NOT pass args if the target method does NOT accept them' do
200
200
  opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
201
201
  st = AASM::Transition.new(opts)
202
202
  args = {:arg1 => '1', :arg2 => '2'}
203
- obj = double('object')
203
+ obj = double('object', :aasm => 'aasm')
204
204
 
205
205
  def obj.test
206
206
  'success'
@@ -208,7 +208,22 @@ describe AASM::Transition, '- when executing the transition with an :on_transtio
208
208
 
209
209
  return_value = st.execute(obj, args)
210
210
 
211
- return_value.should == 'success'
211
+ expect(return_value).to eq('success')
212
+ end
213
+
214
+ it 'should allow accessing the from_state and the to_state' do
215
+ opts = {:from => 'foo', :to => 'bar', :on_transition => :test}
216
+ st = AASM::Transition.new(opts)
217
+ args = {:arg1 => '1', :arg2 => '2'}
218
+ obj = double('object', :aasm => AASM::InstanceBase.new('object'))
219
+
220
+ def obj.test(args)
221
+ "from: #{aasm.from_state} to: #{aasm.to_state}"
222
+ end
223
+
224
+ return_value = st.execute(obj, args)
225
+
226
+ expect(return_value).to eq('from: foo to: bar')
212
227
  end
213
228
 
214
229
  end
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: 3.0.25
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Barron
@@ -11,90 +11,90 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-12-16 00:00:00.000000000 Z
14
+ date: 2014-01-29 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - '>='
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: sdoc
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0'
37
37
  type: :development
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
- - - '>='
41
+ - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: rspec
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ~>
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '2.14'
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - ~>
55
+ - - ">="
56
56
  - !ruby/object:Gem::Version
57
57
  version: '2.14'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rr
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
- - - '>='
62
+ - - ">="
63
63
  - !ruby/object:Gem::Version
64
64
  version: '0'
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: minitest
74
74
  requirement: !ruby/object:Gem::Requirement
75
75
  requirements:
76
- - - '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '>='
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  - !ruby/object:Gem::Dependency
87
87
  name: mime-types
88
88
  requirement: !ruby/object:Gem::Requirement
89
89
  requirements:
90
- - - ~>
90
+ - - "~>"
91
91
  - !ruby/object:Gem::Version
92
92
  version: '1.25'
93
93
  type: :development
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - ~>
97
+ - - "~>"
98
98
  - !ruby/object:Gem::Version
99
99
  version: '1.25'
100
100
  description: AASM is a continuation of the acts as state machine rails plugin, built
@@ -104,9 +104,9 @@ executables: []
104
104
  extensions: []
105
105
  extra_rdoc_files: []
106
106
  files:
107
- - .document
108
- - .gitignore
109
- - .travis.yml
107
+ - ".document"
108
+ - ".gitignore"
109
+ - ".travis.yml"
110
110
  - API
111
111
  - CHANGELOG.md
112
112
  - Gemfile
@@ -117,6 +117,7 @@ files:
117
117
  - aasm.gemspec
118
118
  - gemfiles/rails_3.2.gemfile
119
119
  - gemfiles/rails_4.0.gemfile
120
+ - gemfiles/rails_4.1.gemfile
120
121
  - lib/aasm.rb
121
122
  - lib/aasm/aasm.rb
122
123
  - lib/aasm/base.rb
@@ -132,6 +133,7 @@ files:
132
133
  - lib/aasm/state_machine.rb
133
134
  - lib/aasm/transition.rb
134
135
  - lib/aasm/version.rb
136
+ - spec/database.rb
135
137
  - spec/database.yml
136
138
  - spec/en.yml
137
139
  - spec/en_deprecated_style.yml
@@ -143,6 +145,7 @@ files:
143
145
  - spec/models/conversation.rb
144
146
  - spec/models/father.rb
145
147
  - spec/models/foo.rb
148
+ - spec/models/guardian.rb
146
149
  - spec/models/invalid_persistor.rb
147
150
  - spec/models/mongoid/no_scope_mongoid.rb
148
151
  - spec/models/mongoid/simple_mongoid.rb
@@ -158,12 +161,12 @@ files:
158
161
  - spec/models/transactor.rb
159
162
  - spec/models/validator.rb
160
163
  - spec/models/worker.rb
161
- - spec/schema.rb
162
164
  - spec/spec_helper.rb
163
165
  - spec/unit/api_spec.rb
164
166
  - spec/unit/callbacks_spec.rb
165
167
  - spec/unit/complex_example_spec.rb
166
168
  - spec/unit/event_spec.rb
169
+ - spec/unit/guard_spec.rb
167
170
  - spec/unit/initial_state_spec.rb
168
171
  - spec/unit/inspection_spec.rb
169
172
  - spec/unit/localizer_spec.rb
@@ -185,12 +188,12 @@ require_paths:
185
188
  - lib
186
189
  required_ruby_version: !ruby/object:Gem::Requirement
187
190
  requirements:
188
- - - '>='
191
+ - - ">="
189
192
  - !ruby/object:Gem::Version
190
193
  version: '0'
191
194
  required_rubygems_version: !ruby/object:Gem::Requirement
192
195
  requirements:
193
- - - '>='
196
+ - - ">="
194
197
  - !ruby/object:Gem::Version
195
198
  version: '0'
196
199
  requirements: []
@@ -200,6 +203,7 @@ signing_key:
200
203
  specification_version: 4
201
204
  summary: State machine mixin for Ruby objects
202
205
  test_files:
206
+ - spec/database.rb
203
207
  - spec/database.yml
204
208
  - spec/en.yml
205
209
  - spec/en_deprecated_style.yml
@@ -211,6 +215,7 @@ test_files:
211
215
  - spec/models/conversation.rb
212
216
  - spec/models/father.rb
213
217
  - spec/models/foo.rb
218
+ - spec/models/guardian.rb
214
219
  - spec/models/invalid_persistor.rb
215
220
  - spec/models/mongoid/no_scope_mongoid.rb
216
221
  - spec/models/mongoid/simple_mongoid.rb
@@ -226,12 +231,12 @@ test_files:
226
231
  - spec/models/transactor.rb
227
232
  - spec/models/validator.rb
228
233
  - spec/models/worker.rb
229
- - spec/schema.rb
230
234
  - spec/spec_helper.rb
231
235
  - spec/unit/api_spec.rb
232
236
  - spec/unit/callbacks_spec.rb
233
237
  - spec/unit/complex_example_spec.rb
234
238
  - spec/unit/event_spec.rb
239
+ - spec/unit/guard_spec.rb
235
240
  - spec/unit/initial_state_spec.rb
236
241
  - spec/unit/inspection_spec.rb
237
242
  - spec/unit/localizer_spec.rb
data/spec/schema.rb DELETED
@@ -1,35 +0,0 @@
1
- ActiveRecord::Schema.define(:version => 0) do
2
-
3
- %w{gates readers writers transients simples simple_new_dsls no_scopes thieves localizer_test_models persisted_states provided_and_persisted_states}.each do |table_name|
4
- create_table table_name, :force => true do |t|
5
- t.string "aasm_state"
6
- end
7
- end
8
-
9
- create_table "validators", :force => true do |t|
10
- t.string "name"
11
- t.string "status"
12
- end
13
-
14
- create_table "transactors", :force => true do |t|
15
- t.string "name"
16
- t.string "status"
17
- t.integer "worker_id"
18
- end
19
-
20
- create_table "workers", :force => true do |t|
21
- t.string "name"
22
- t.string "status"
23
- end
24
-
25
- create_table "invalid_persistors", :force => true do |t|
26
- t.string "name"
27
- t.string "status"
28
- end
29
-
30
- create_table "fathers", :force => true do |t|
31
- t.string "aasm_state"
32
- t.string "type"
33
- end
34
-
35
- end