PageRenderTime 76ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/vendor/plugins/state_machine/test/unit/integrations_test.rb

https://bitbucket.org/systech3/boxyroom
Ruby | 42 lines | 34 code | 8 blank | 0 comment | 0 complexity | 533f17d3b1f6b352f2681c457d497f4a MD5 | raw file
Possible License(s): JSON, MIT
  1. require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
  2. class IntegrationMatcherTest < Test::Unit::TestCase
  3. def setup
  4. @klass = Class.new
  5. end
  6. def test_should_return_nil_if_no_match_found
  7. assert_nil StateMachine::Integrations.match(@klass)
  8. end
  9. def test_should_return_integration_class_if_match_found
  10. integration = Module.new do
  11. def self.matches?(klass)
  12. true
  13. end
  14. end
  15. StateMachine::Integrations.const_set('Custom', integration)
  16. assert_equal integration, StateMachine::Integrations.match(@klass)
  17. ensure
  18. StateMachine::Integrations.send(:remove_const, 'Custom')
  19. end
  20. end
  21. class IntegrationFinderTest < Test::Unit::TestCase
  22. def test_should_find_active_record
  23. assert_equal StateMachine::Integrations::ActiveRecord, StateMachine::Integrations.find(:active_record)
  24. end
  25. def test_should_find_data_mapper
  26. assert_equal StateMachine::Integrations::DataMapper, StateMachine::Integrations.find(:data_mapper)
  27. end
  28. def test_should_find_sequel
  29. assert_equal StateMachine::Integrations::Sequel, StateMachine::Integrations.find(:sequel)
  30. end
  31. def test_should_raise_an_exception_if_invalid
  32. assert_raise(NameError) { StateMachine::Integrations.find(:invalid) }
  33. end
  34. end