0
我有以下整合步驟來檢查.credits_count
類和0 credits on it
。如何匹配水豚的css類和文本
it "show credits available at the top." do
user = Factory.create(:user)
login_as(user, :scope => :user)
page.should have_selector('.credits_count', text: '0 credits')
end
的問題是,我收到以下錯誤時.credits_count
是其文本的頁面上。
Credits when user is non-enabled show user credits available at the top.
Failure/Error: page.should have_selector('.credits_count', text: '0 credits')
expected css ".credits_count" with text "0 credits" to return something
# ./spec/requests/credits_spec.rb:12:in `block (3 levels) in <top (required)>'
任何想法爲什麼它沒有看到.credits_count
選擇器?
視圖佈局看起來像這樣。
# app/views/layouts/application.html.haml
- if current_user
%li.credits_count
= current_user.credits_count
credits
您創建了credits_count作爲您在查看文件中的li標記的id,但是您正在尋找credits_count作爲類。我認爲這可能是問題。 – Mohanraj
好點,但恐怕它仍然發生,甚至修復(給出相同的錯誤)。 – Martin
這可能與「0學分」跨兩行分開的事實有關。如果將'text:'0''部分的參數取出爲'have_selector',會怎麼樣?如果通過,那麼你知道文本是問題。 –