Sha256: 0e9bb8954fb774187be5f69732438f55e14eb2b20888e9abc0969e077e09512b

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

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

class AssertionsBaseTest < MiniTest::Test
  include EnumStateMachine::Assertions
  
  def default_test
  end
end

class AssertValidKeysTest < AssertionsBaseTest
  def test_should_not_raise_exception_if_key_is_valid
    assert_nothing_raised { assert_valid_keys({:name => 'foo', :value => 'bar'}, :name, :value, :force) }
  end
  
  def test_should_raise_exception_if_key_is_invalid
    exception = assert_raises(ArgumentError) {
      assert_valid_keys({:name => 'foo', :value => 'bar', :invalid => true}, :name, :value, :force)
    }
    assert_equal 'Invalid key(s): invalid', exception.message
  end
end

class AssertExclusiveKeysTest < AssertionsBaseTest
  def test_should_not_raise_exception_if_no_keys_found
    assert_nothing_raised { assert_exclusive_keys({:on => :park}, :only, :except) }
  end
  
  def test_should_not_raise_exception_if_one_key_found
    assert_nothing_raised { assert_exclusive_keys({:only => :parked}, :only, :except) }
    assert_nothing_raised { assert_exclusive_keys({:except => :parked}, :only, :except) }
  end
  
  def test_should_raise_exception_if_two_keys_found
    exception = assert_raises(ArgumentError) {
      assert_exclusive_keys({:only => :parked, :except => :parked}, :only, :except)
    }
    assert_equal 'Conflicting keys: only, except', exception.message
  end
  
  def test_should_raise_exception_if_multiple_keys_found
    exception = assert_raises(ArgumentError) {
      assert_exclusive_keys({:only => :parked, :except => :parked, :on => :park}, :only, :except, :with)
    }
    assert_equal 'Conflicting keys: only, except', exception.message
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
enum_state_machine-0.8.0 test/unit/assertions_test.rb
enum_state_machine-0.7.0 test/unit/assertions_test.rb
enum_state_machine-0.6.0 test/unit/assertions_test.rb
enum_state_machine-0.5.0 test/unit/assertions_test.rb
enum_state_machine-0.4.1 test/unit/assertions_test.rb
enum_state_machine-0.4.0 test/unit/assertions_test.rb
enum_state_machine-0.3.0 test/unit/assertions_test.rb
enum_state_machine-0.2.0 test/unit/assertions_test.rb