Sha256: f7eef560233f9ac8bd594edd703cd17df3374431ca798b86c2c65244bfce419b

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'


context 'AssertValidKeys' do
  it 'should_not_raise_exception_if_key_is_valid' do
    assert_nothing_raised { {:name => 'foo', :value => 'bar'}.assert_valid_keys(:name, :value, :force) }
  end

  it 'should_raise_exception_if_key_is_invalid' do
    assert_raise(ArgumentError) { {:name => 'foo', :value => 'bar', :invalid => true}.assert_valid_keys(:name, :value, :force) }
  end
end

context 'AssertExclusiveKeys' do
  it 'should_not_raise_exception_if_no_keys_found' do
    assert_nothing_raised { {:on => :park}.assert_exclusive_keys(:only, :except) }
  end

  it 'should_not_raise_exception_if_one_key_found' do
    assert_nothing_raised { {:only => :parked}.assert_exclusive_keys(:only, :except) }
    assert_nothing_raised { {:except => :parked}.assert_exclusive_keys(:only, :except) }
  end

  it 'should_raise_exception_if_two_keys_found' do
    assert_raise(ArgumentError) { {:only => :parked, :except => :parked}.assert_exclusive_keys(:only, :except) }
  end

  it 'should_raise_exception_if_multiple_keys_found' do
    assert_raise(ArgumentError) { {:only => :parked, :except => :parked, :on => :park}.assert_exclusive_keys(:only, :except, :with) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
state_machines-0.0.2 spec/state_machines/assertions_spec.rb