【发布时间】:2013-12-05 19:16:40
【问题描述】:
我目前正在使用 minitest capybara 进行测试,但我的一项测试出现错误
Unable to find link or button "Edit Profile"
这是我的测试
require "test_helper"
feature "as a student I want a working user system so grade = good" do
scenario "users can update profile" do
dude_sign_up
dude_log_in
click_on "Edit Profile"
click_on "Update"
page.must_have_content "Profile was successfully updated"
end
end
测试助手的两个助手方法
def dude_sign_up
visit new_user_path
fill_in "Name", with: 'thedude'
fill_in "Email", with: "dude@dudecool.com"
fill_in "Password", with: 'password'
fill_in "Password confirmation", with: 'password'
click_on "Sign Up"
end
def dude_log_in
visit posts_path
fill_in "Email", with: "dude@dudecool.com"
fill_in "Password", with: 'password'
click_on "Log In"
end
如果需要的话,这里是我在 application.html.erb 中渲染的 _nav,介于收益之间和之上
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<ul class="nav navbar-nav navbar-right">
<li><%= link_to 'Home', root_path %></li>
<li><%= link_to 'About', about_path %></li>
<li><%= link_to "The Blog", posts_path %></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Registration<b class="caret"></b></a>
<ul class="dropdown-menu">
<% if current_user %>
<td><%= link_to 'Edit Profile', edit_user_path(current_user) %></td>
<li><%= link_to "Users", users_path %></li>
<li><%= link_to "Log out", logout_path %></li>
<% else %>
<li><%= link_to 'Sign Up', signup_path %></a></li>
<li><%= link_to 'Log In', login_path %></li>
<% end %>
</ul>
</li>
</ul>
</div>
</nav>
如果我点击所有内容并浏览它,它就可以正常工作。我没有使用固定装置是我的问题的原因吗?
【问题讨论】:
-
您确定用户登录成功了吗?
-
是的,因为我运行了另一个测试以查看登录的 flash 消息是否出现并且确实出现了,我的意思是测试通过了
标签: ruby-on-rails capybara minitest