test/lib/vedeu/support/menu_test.rb in vedeu-0.0.40 vs test/lib/vedeu/support/menu_test.rb in vedeu-0.0.41

- old
+ new

@@ -22,34 +22,37 @@ it 'returns nil when no item is selected' do menu.selected.must_equal(nil) end it 'returns the selected index when an item is selected' do - menu.next_item.select_item + menu.next_item + menu.select_item menu.selected.must_equal(1) end end describe '#current_item' do - it 'returns a tuple containing the current index and item' do - menu.current_item.must_equal([0, 'hydrogen']) + it 'returns the current item from the collection' do + menu.current_item.must_equal('hydrogen') end - it 'when the current item has changed, the tuple will change' do - menu.next_item.next_item - menu.current_item.must_equal([2, 'nitrogen']) + it 'when the current item has changed' do + menu.next_item + menu.next_item + menu.current_item.must_equal('nitrogen') end end describe '#selected_item' do it 'returns nil when nothing is selected' do menu.selected_item.must_equal(nil) end - it 'returns a tuple containing the selected index and item' do - menu.next_item.select_item - menu.selected_item.must_equal([1, 'carbon']) + it 'returns the selected item from the collection' do + menu.next_item + menu.select_item + menu.selected_item.must_equal('carbon') end end describe '#items' do it 'returns a tuple' do @@ -62,22 +65,24 @@ ] ) end it 'returns a tuple when the current has changed' do - menu.next_item.items.must_equal( + menu.next_item + menu.items.must_equal( [ [false, false, 'hydrogen'], [false, true, 'carbon'], [false, false, 'nitrogen'], [false, false, 'oxygen'] ] ) end it 'returns a tuple when an item is selected' do - menu.next_item.select_item + menu.next_item + menu.select_item menu.items.must_equal( [ [false, false, 'hydrogen'], [true, true, 'carbon'], [false, false, 'nitrogen'], @@ -86,12 +91,14 @@ ) end it 'returns a tuple when the current has changed and an item ' \ 'is selected' do - menu.next_item.select_item - menu.next_item.next_item + menu.next_item + menu.select_item + menu.next_item + menu.next_item menu.items.must_equal( [ [false, false, 'hydrogen'], [true, false, 'carbon'], [false, false, 'nitrogen'], @@ -102,127 +109,158 @@ end describe '#render' do it 'returns a tuple' do menu.render.must_equal( - [' > hydrogen', ' carbon', ' nitrogen', ' oxygen'] + [ + ' > hydrogen', + ' carbon', + ' nitrogen', + ' oxygen' + ] ) end it 'returns a tuple when the current has changed' do - menu.next_item.render.must_equal( - [' hydrogen', ' > carbon', ' nitrogen', ' oxygen'] + menu.next_item + menu.render.must_equal( + [ + ' hydrogen', + ' > carbon', + ' nitrogen', + ' oxygen' + ] ) end it 'returns a tuple when an item is selected' do - menu.next_item.select_item + menu.next_item + menu.select_item menu.render.must_equal( - [' hydrogen', '*> carbon', ' nitrogen', ' oxygen'] + [ + ' hydrogen', + '*> carbon', + ' nitrogen', + ' oxygen' + ] ) end it 'returns a tuple when the current has changed and an item ' \ 'is selected' do - menu.next_item.select_item - menu.next_item.next_item + menu.next_item + menu.select_item + menu.next_item + menu.next_item menu.render.must_equal( - [' hydrogen', '* carbon', ' nitrogen', ' > oxygen'] + [ + ' hydrogen', + '* carbon', + ' nitrogen', + ' > oxygen' + ] ) end end describe '#top_item' do it 'sets current to the index of the first item' do menu.next_item - menu.top_item.current.must_equal(0) + menu.top_item + menu.current.must_equal(0) end - it 'returns the instance' do - menu.top_item.must_equal(menu) + it 'returns the items' do + menu.top_item.must_equal(menu.items) end - - it 'is chainable' do - menu.top_item.current.must_equal(0) - end end describe '#bottom_item' do it 'sets current to the index of the last item' do - menu.bottom_item.current.must_equal(3) + menu.bottom_item + menu.current.must_equal(3) end - it 'returns the instance' do - menu.top_item.must_equal(menu) + it 'returns the items' do + menu.bottom_item.must_equal(menu.items) end - - it 'is chainable' do - menu.bottom_item.current.must_equal(3) - end end describe '#next_item' do it 'sets the current to the index of the next item' do - menu.next_item.current.must_equal(1) + menu.next_item + menu.current.must_equal(1) end - it 'returns the instance' do - menu.next_item.must_equal(menu) + it 'returns the items' do + menu.next_item.must_equal(menu.items) end - it 'is chainable but does not loop' do - menu.next_item.next_item.next_item.next_item.next_item.current.must_equal(3) + it 'does not loop' do + menu.next_item + menu.next_item + menu.next_item + menu.next_item + menu.next_item + menu.current.must_equal(3) end end describe '#prev_item' do it 'does not loop' do - menu.prev_item.current.must_equal(0) + menu.prev_item + menu.current.must_equal(0) end it 'sets the current to the index of the previous item' do - menu.next_item.next_item.prev_item.current.must_equal(1) + menu.next_item + menu.next_item + menu.prev_item + menu.current.must_equal(1) end - it 'returns the instance' do - menu.prev_item.must_equal(menu) + it 'returns the items' do + menu.prev_item.must_equal(menu.items) end - it 'is chainable' do - menu.next_item.next_item.next_item.prev_item.prev_item.current.must_equal(1) + it 'does not loop' do + menu.next_item + menu.next_item + menu.next_item + menu.prev_item + menu.prev_item + menu.current.must_equal(1) end end describe '#select_item' do it 'sets the selected index to the current index' do - menu.select_item.selected.must_equal(0) + menu.select_item + menu.selected.must_equal(0) end it 'sets the selected index to the current index' do - menu.next_item.select_item.selected.must_equal(1) + menu.next_item + menu.select_item + menu.selected.must_equal(1) end - it 'returns the instance' do - menu.select_item.must_equal(menu) + it 'returns the items' do + menu.select_item.must_equal(menu.items) end - - it 'is chainable' do - menu.select_item.selected.must_equal(0) - end end describe '#deselect_item' do it 'sets the selected index to nil' do - menu.next_item.next_item.select_item - menu.deselect_item.selected.must_equal(nil) + menu.next_item + menu.next_item + menu.select_item + menu.deselect_item + menu.selected.must_equal(nil) end - it 'returns the instance' do - menu.deselect_item.must_equal(menu) - end - - it 'is chainable' do - menu.deselect_item.selected.must_equal(nil) + it 'returns the items' do + menu.deselect_item.must_equal(menu.items) end end describe '#last' do it 'returns the index of the last item' do