我在h1元素中有一个带有“设置”的索引视图。
<div id="settings-main-container">
<div id="settings-main-title">
<h1 id="settings-title">Settings</h1>
</div>
<%=link_to admin_clients_index_path do%>
<div class="settings-button">
Select Active Client
</div>
<%end%>
<%=link_to admin_settings_assign_users_to_clients_index_path do%>
<div class="settings-button">
Assign Users to Clients
</div>
<%end%>
<%=link_to destroy_user_session_path, method: :delete do%>
<div class="settings-button">
Logout
</div>
<%end%>
</div>
我已经设置好测试
describe "GET index" do
render_views
...
it "should have text on the screen" do
get :index
response.should have_text("Settings")
end
end
我不断收到错误
Failure/Error: response.should have_text("Settings")
expected to find text "Settings" in "#"
任何帮助将不胜感激。
答案 0 :(得分:1)
response
包含标头,响应代码和响应正文之类的内容。因此,如果要检查呈现的视图,则应检查response.body
:
response.body.should have_text("Settings")