我正在用水豚黃瓜來測試我的應用程序。但是,我似乎無法在我的頁面中找到錨鏈接。我已經使用save_and_open_page
調試特定的步驟,這是輸出頁面的相關framgent:使用水豚找不到鏈接
<ul class='nav navbar-nav navbar-right'>
<li><a href="http://www.example.com/en/accounts/login">Login</a></li>
<li><a href="http://www.example.com/en/accounts/register">Register</a></li>
</ul>
我的方案的步驟失敗了,包括下面的代碼:
expect(page).to have_link("Login")
expect(page).to have_link("Register")
失敗的消息我從水豚得到的是:
Capybara::ExpectationNotMet: expected to find link "Login" but there were no matches. Also found "", which matched the selector but not all filters.
我曾嘗試使用一個ID,姓名等來代替我的期望,但沒有運氣。
有沒有人可能有一個想法,我怎麼能得到這個工作?
編輯:
一條信息,可能證明是有用的:
前面提到的兩個環節駐留在包含在我探在我的測試頁面的佈局部分:
_title_bar.html.haml
:包括登錄並註冊鏈接如上所示layout.html.haml
:包括_partial.html.haml局部login.html.haml
:使用layout.html.haml作爲templat
ë呈現。
我注意到,當我把鏈接直接在login.html.haml中,我的測試通過。當我將它們包含在layout.html.haml或_title_bar.html.haml中時,水豚不能解決它們。
在這個區塊做其他匹配器的工作?請發佈您的完整規範文件或至少包含這兩個'expect'行的示例。 – vee
我已經發布了我的完整步驟定義失敗。 –
查看「調試水豚」下的調試技術http://nofail.de/2013/10/debugging-rails-applications-in-development/ – phoet