Sha256: c4dd4c3f000f5c5a9d4b9d9c96e73fb527d39bd94cd8c216d8d0f3a4995cb5cd

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../test_helper')

class IntegrationMatcherTest < Test::Unit::TestCase
  def setup
    @klass = Class.new
  end
  
  def test_should_return_nil_if_no_match_found
    assert_nil StateMachine::Integrations.match(@klass)
  end
  
  def test_should_return_integration_class_if_match_found
    integration = Module.new do
      def self.matches?(klass)
        true
      end
    end
    StateMachine::Integrations.const_set('Custom', integration)
    
    assert_equal integration, StateMachine::Integrations.match(@klass)
  ensure
    StateMachine::Integrations.send(:remove_const, 'Custom')
  end
end

class IntegrationFinderTest < Test::Unit::TestCase
  def test_should_find_base
    assert_equal StateMachine::Integrations::Base, StateMachine::Integrations.find(:base)
  end
  
  def test_should_find_active_model
    assert_equal StateMachine::Integrations::ActiveModel, StateMachine::Integrations.find(:active_model)
  end
  
  def test_should_find_active_record
    assert_equal StateMachine::Integrations::ActiveRecord, StateMachine::Integrations.find(:active_record)
  end
  
  def test_should_find_data_mapper
    assert_equal StateMachine::Integrations::DataMapper, StateMachine::Integrations.find(:data_mapper)
  end
  
  def test_should_find_mongo_mapper
    assert_equal StateMachine::Integrations::MongoMapper, StateMachine::Integrations.find(:mongo_mapper)
  end
  
  def test_should_find_sequel
    assert_equal StateMachine::Integrations::Sequel, StateMachine::Integrations.find(:sequel)
  end
  
  def test_should_raise_an_exception_if_invalid
    assert_raise(NameError) { StateMachine::Integrations.find(:invalid) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
state_machine-0.10.3 test/unit/integrations_test.rb
state_machine-0.10.2 test/unit/integrations_test.rb
state_machine-0.10.1 test/unit/integrations_test.rb
state_machine-0.10.0 test/unit/integrations_test.rb