2013-07-26 22 views
0

我在我的應用程序下面的代碼:測試一個html類的標題標籤與水豚

<div class="btn btn-mini disabled" title="<%= t('title.button.loan.borrow.disable.already_current') %>"><%= t('button.loan.borrow.after_confirmation') %></div> 

我想測試我的網頁上這個按鈕的存在,同時在考慮標題標籤。我怎樣才能做到這一點 ?

it { should have_css('.btn.disabled', 
        text: t('button.loan.borrow.after_confirmation'), 
# (False line)  title: t('title.button.loan.borrow.disable.already_current')) } 
+0

有對你的期望三個約束也許是矯枉過正,使一個相當脆弱的規範。您應該考慮只使用足夠的約束來檢查按鈕的存在,而不用擔心所使用的特定本地化。 –

+0

丹尼爾,我有多個原因顯示禁用的按鈕,我想通過HTML標題標籤解釋它們。但是如果我想檢查我的按鈕的標題是否相應地顯示在上下文中,我必須測試它... –

回答

1

你應該使用attribute selector

it { should have_css(".btn.disabled[title='#{t('title.button.loan.borrow.disable.already_current')}']", 
       text: t('button.ownership.take.after_confirmation'),