Sha256: b2794bca1e8a7f448af8570383d76ecf9928bec3926cc878ff76a650d84043fc

Contents?: true

Size: 1.61 KB

Versions: 56

Compression:

Stored size: 1.61 KB

Contents

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

class AssertionsBaseTest < Test::Unit::TestCase
  include StateMachine::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_raise(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_raise(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_raise(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

56 entries across 56 versions & 15 rubygems

Version Path
state_machine_updated_for_ruby_3_2-2.0.0 test/unit/assertions_test.rb
telvue_state_machine-1.2.3 test/unit/assertions_test.rb
telvue_state_machine-1.2.2 test/unit/assertions_test.rb
state_machine_deuxito-0.0.1 test/unit/assertions_test.rb
telvue_state_machine-1.2.1 test/unit/assertions_test.rb
cm-state_machine-1.2.0.1 test/unit/assertions_test.rb
spree-state_machine-2.0.0.beta4 test/unit/assertions_test.rb
spree-state_machine-2.0.0.beta3 test/unit/assertions_test.rb
spree-state_machine-2.0.0.beta2 test/unit/assertions_test.rb
spree-state_machine-2.0.0.beta1 test/unit/assertions_test.rb
culturecode-state_machine-1.2.1 test/unit/assertions_test.rb
joelind-state_machine-0.8.1 test/unit/assertions_test.rb
pluginaweek-state_machine-0.8.0 test/unit/assertions_test.rb
automat-1.2.0 test/unit/assertions_test.rb
glebtv_state_machine-1.3.0 test/unit/assertions_test.rb
state_machine-1.2.0 test/unit/assertions_test.rb
state_machine-1.1.2 test/unit/assertions_test.rb
state_machine-1.1.1 test/unit/assertions_test.rb
state_machine-1.1.0 test/unit/assertions_test.rb
state_machine-1.0.3 test/unit/assertions_test.rb