Sha256: c36e66e31fd92a70570924dfe13076c7fe91621f83018b127c25f39516497378

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

## ruby -Itest -Ilib test/state_objects_exceptions_test.rb
require 'test_helper'

#
# test bad data and exceptions
#
                            
class LightGreenState  < StateObjects::Base
  state_object_values :green, 'G', 'Walk' 
end        

class ModelUnderTest < SuperModel::Base
  extend StateObjects::ModelAdditions
  state_objects :color_state,
     LightGreenState

  begin 
    state_object_events :color_state, :missing_event
                                                                                   
  rescue RuntimeError => ex
    @@exception_missing_event = ex
  end

  def self.exception_missing_event
    @@exception_missing_event
  end

end

class TranslateOptionsForExTest < Test::Unit::TestCase
  def setup
    @model  = ModelUnderTest
  end

  def test_exception_missing_event
    assert_equal RuntimeError, ModelUnderTest.exception_missing_event.class
    assert_equal "Invalid state class LightGreenState must implement #missing_event",
                  ModelUnderTest.exception_missing_event.message
  end 

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
state_objects-0.0.7 test/state_objects_exeptions_test.rb
state_objects-0.0.6 test/state_objects_exeptions_test.rb
state_objects-0.0.4 test/state_objects_exeptions_test.rb
state_objects-0.0.3 test/state_objects_exeptions_test.rb