'Check that only those menu items should be there with the Capybara

Friends, I have a menu named GAR with the items: GAR Rules, GAE Rules and Gar/Gae Processes log. How to validate if only these items should be there?. If a different item is entered, the test must fail. If I use expect to validate the items and another item is implemented, the test will continue to pass.

I tried that: page.all('select#tbm2').map(&:value).should == %w(Regras GAR Regras GAE Log Processamentos GAR/GAE)

<div id="tbm2" class="tb">
      <div id="TBH_tbm2" onclick="javascript:showMenu('tbm2','tbm2', true, true)" class="tbh">GAR</div>
      <div id="TBB_tbm2" class="tbb">
         <div onclick="sendEvent(0,event,this,searchImage(this),0,'','1370','Menu','','','.13.3','',''); " class="tbi tbiSel">
            <div>
               <div class="tbiIcon"><img src="r/std/static/pixel.gif" class="icon icon_config" draggable="false"></div>
            </div>
            <div>Regras GAR</div>
         </div>
         <div onclick="sendEvent(0,event,this,searchImage(this),0,'','1370','Menu','','','.13.4','',''); " class="tbi">
            <div>
               <div class="tbiIcon"><img src="r/std/static/collapse16.gif" class="icon" draggable="false"></div>
            </div>
            <div>Regras GAE</div>
         </div>
         <div onclick="sendEvent(0,event,this,searchImage(this),0,'','1370','Menu','','','.13.6','',''); " class="tbi">
            <div>
               <div class="tbiIcon"><img src="r/std/icons/listini64.png" class="icon" draggable="false"></div>
            </div>
            <div>Log Processamentos GAR/GAE</div>
         </div>
      </div>
   </div>
</td>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source