state_machine 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -246,20 +246,25 @@ begin
246
246
  end
247
247
  end
248
248
 
249
- class MachineWithNonColumnStateAttributeTest < ActiveRecord::TestCase
249
+ class MachineWithNonColumnStateAttributeUndefinedTest < ActiveRecord::TestCase
250
250
  def setup
251
- @model = new_model
251
+ @model = new_model do
252
+ def initialize
253
+ # Skip attribute initialization
254
+ end
255
+ end
256
+
252
257
  @machine = StateMachine::Machine.new(@model, :status, :initial => :parked)
253
258
  @machine.other_states(:idling)
254
259
  @record = @model.new
255
260
  end
256
261
 
257
- def test_should_define_a_reader_attribute_for_the_attribute
258
- assert @record.respond_to?(:status)
262
+ def test_should_not_define_a_reader_attribute_for_the_attribute
263
+ assert !@record.respond_to?(:status)
259
264
  end
260
265
 
261
- def test_should_define_a_writer_attribute_for_the_attribute
262
- assert @record.respond_to?(:status=)
266
+ def test_should_not_define_a_writer_attribute_for_the_attribute
267
+ assert !@record.respond_to?(:status=)
263
268
  end
264
269
 
265
270
  def test_should_define_an_attribute_predicate
@@ -268,10 +273,22 @@ begin
268
273
 
269
274
  def test_should_raise_exception_on_predicate_without_parameters
270
275
  old_verbose, $VERBOSE = $VERBOSE, nil
271
- assert_raise(ArgumentError) { @record.status? }
276
+ assert_raise(NoMethodError) { @record.status? }
272
277
  ensure
273
278
  $VERBOSE = old_verbose
274
279
  end
280
+ end
281
+
282
+ class MachineWithNonColumnStateAttributeDefinedTest < ActiveRecord::TestCase
283
+ def setup
284
+ @model = new_model do
285
+ attr_accessor :status
286
+ end
287
+
288
+ @machine = StateMachine::Machine.new(@model, :status, :initial => :parked)
289
+ @machine.other_states(:idling)
290
+ @record = @model.new
291
+ end
275
292
 
276
293
  def test_should_return_false_for_predicate_if_does_not_match_current_value
277
294
  assert !@record.status?(:idling)
@@ -176,19 +176,39 @@ begin
176
176
  end
177
177
  end
178
178
 
179
- class MachineWithNonColumnStateAttributeTest < BaseTestCase
179
+ class MachineWithNonColumnStateAttributeUndefinedTest < BaseTestCase
180
180
  def setup
181
- @resource = new_resource
181
+ @resource = new_resource do
182
+ def initialize
183
+ # Skip attribute initialization
184
+ end
185
+ end
186
+
182
187
  @machine = StateMachine::Machine.new(@resource, :status, :initial => 'parked')
183
188
  @record = @resource.new
184
189
  end
185
190
 
186
- def test_should_define_a_reader_attribute_for_the_attribute
187
- assert @record.respond_to?(:status)
191
+ def test_should_not_define_a_reader_attribute_for_the_attribute
192
+ assert !@record.respond_to?(:status)
188
193
  end
189
194
 
190
- def test_should_define_a_writer_attribute_for_the_attribute
191
- assert @record.respond_to?(:status=)
195
+ def test_should_not_define_a_writer_attribute_for_the_attribute
196
+ assert !@record.respond_to?(:status=)
197
+ end
198
+
199
+ def test_should_define_an_attribute_predicate
200
+ assert @record.respond_to?(:status?)
201
+ end
202
+ end
203
+
204
+ class MachineWithNonColumnStateAttributeDefinedTest < BaseTestCase
205
+ def setup
206
+ @resource = new_resource do
207
+ attr_accessor :status
208
+ end
209
+
210
+ @machine = StateMachine::Machine.new(@resource, :status, :initial => 'parked')
211
+ @record = @resource.new
192
212
  end
193
213
 
194
214
  def test_should_set_initial_state_on_created_object
@@ -443,5 +463,5 @@ begin
443
463
  end
444
464
  end
445
465
  rescue LoadError
446
- $stderr.puts 'Skipping DataMapper tests. `gem install dm-core rspec hoe launchy do_sqlite3` and try again.'
466
+ $stderr.puts 'Skipping DataMapper tests. `gem install dm-core cucumber rspec hoe launchy do_sqlite3` and try again.'
447
467
  end
@@ -162,19 +162,39 @@ begin
162
162
  end
163
163
  end
164
164
 
165
- class MachineWithNonColumnStateAttributeTest < BaseTestCase
165
+ class MachineWithNonColumnStateAttributeUndefinedTest < BaseTestCase
166
166
  def setup
167
- @model = new_model
167
+ @model = new_model do
168
+ def initialize
169
+ # Skip attribute initialization
170
+ end
171
+ end
172
+
168
173
  @machine = StateMachine::Machine.new(@model, :status, :initial => 'parked')
169
174
  @record = @model.new
170
175
  end
171
176
 
172
- def test_should_define_a_reader_attribute_for_the_attribute
173
- assert @record.respond_to?(:status)
177
+ def test_should_not_define_a_reader_attribute_for_the_attribute
178
+ assert !@record.respond_to?(:status)
174
179
  end
175
180
 
176
- def test_should_define_a_writer_attribute_for_the_attribute
177
- assert @record.respond_to?(:status=)
181
+ def test_should_not_define_a_writer_attribute_for_the_attribute
182
+ assert !@record.respond_to?(:status=)
183
+ end
184
+
185
+ def test_should_define_an_attribute_predicate
186
+ assert @record.respond_to?(:status?)
187
+ end
188
+ end
189
+
190
+ class MachineWithNonColumnStateAttributeDefinedTest < BaseTestCase
191
+ def setup
192
+ @model = new_model do
193
+ attr_accessor :status
194
+ end
195
+
196
+ @machine = StateMachine::Machine.new(@model, :status, :initial => 'parked')
197
+ @record = @model.new
178
198
  end
179
199
 
180
200
  def test_should_set_initial_state_on_created_object
@@ -527,12 +527,8 @@ begin
527
527
  @node = @state.draw(graph)
528
528
  end
529
529
 
530
- def test_should_use_circle_shape
531
- assert_equal 'circle', @node['shape']
532
- end
533
-
534
- def test_should_enabled_fixedsize
535
- assert_equal 'true', @node['fixedsize']
530
+ def test_should_use_ellipse_shape
531
+ assert_equal 'ellipse', @node['shape']
536
532
  end
537
533
 
538
534
  def test_should_set_width_to_one
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Pfeifer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-11 00:00:00 -05:00
12
+ date: 2009-02-11 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15