test/triad_test.rb in triad-0.1.3 vs test/triad_test.rb in triad-0.2.0

- old
+ new

@@ -24,31 +24,16 @@ triad << [:test, 'Test', Object.new] assert_raises(Triad::InvalidAddition){ triad << [:test, 'More', Object.new] } end - - it 'assigns symbol as key' do - object = Object.new - triad << ['OutOfOrder', object, :surprise] - assert_equal [:surprise], triad.keys('OutOfOrder') - assert_equal [:surprise], triad.keys(object) + + it 'accepts strings as values' do + object = "a string as an value" + triad << [:key, 'Descriptor', object] + assert_equal [object], triad.values(:key) end - - it 'assigns string as descriptor' do - object = Object.new - triad << ['OutOfOrder', object, :surprise] - assert_equal ['OutOfOrder'], triad.descriptors(:surprise) - assert_equal ['OutOfOrder'], triad.descriptors(object) - end - - it 'assigns non-symbol, non-string objects as value' do - object = Object.new - triad << ['OutOfOrder', object, :surprise] - assert_equal [object], triad.values(:surprise) - assert_equal [object], triad.values('OutOfOrder') - end end describe Triad, '#update' do let(:triad){ Triad.new } @@ -85,23 +70,23 @@ triad << [:other, 'Other', user] assert_equal [:admin, :other], triad.keys end it 'errors when the given key is not found' do - assert_raises(Triad::KeyNotPresent){ + assert_raises(Triad::ItemNotPresent){ triad.keys(:invalid_key) } end it 'errors when the given descriptor is not found' do - assert_raises(Triad::DescriptorNotPresent){ + assert_raises(Triad::ItemNotPresent){ triad.keys('Invalid Descriptor') } end it 'errors when the given value is not found' do - assert_raises(Triad::ValueNotPresent){ + assert_raises(Triad::ItemNotPresent){ triad.keys(Object.new) } end end @@ -129,23 +114,23 @@ triad << [:other, 'Other', user] assert_equal ['Admin', 'Other'], triad.descriptors end it 'errors when the given descriptor is not found' do - assert_raises(Triad::DescriptorNotPresent){ + assert_raises(Triad::ItemNotPresent){ triad.descriptors('Not Present') } end it 'errors when the given key is not found' do - assert_raises(Triad::KeyNotPresent){ + assert_raises(Triad::ItemNotPresent){ triad.descriptors(:invalid_key) } end it 'errors when the given value is not found' do - assert_raises(Triad::ValueNotPresent){ + assert_raises(Triad::ItemNotPresent){ triad.descriptors(Object.new) } end end @@ -170,16 +155,16 @@ assert_equal [user], triad.values end it 'errors when the given key is not found' do - assert_raises(Triad::KeyNotPresent){ + assert_raises(Triad::ItemNotPresent){ triad.values(:invalid_key) } end it 'errors when the given descriptor is not found' do - assert_raises(Triad::DescriptorNotPresent){ + assert_raises(Triad::ItemNotPresent){ triad.values('Invalid Descriptor') } end end \ No newline at end of file