【发布时间】:2015-04-10 14:45:47
【问题描述】:
我在理解我需要遵循什么流程才能通过此测试时遇到了一点问题。我知道该页面应该有内容,并且我在规范中有相应的数据。我现在不确定我需要遵循哪些步骤才能通过测试。那么如何将测试笔记传递到页面来完成这个测试呢?我在 HAML 工作。
测试:
it "updates a diagnostic report" do
diagnostic_info = FG.create(:diagnostic_info)
diagnostic_info.save!
visit edit_admin_diagnostic_path(diagnostic_info)
fill_in 'diagnostic_info_notes', with: "test notes"
click_button "Save"
page.should have_content("Successfully updated")
page.should have_content("test notes")
end
编辑视图
.field
= label_tag :notes
= f.text_field "notes"
= submit_tag 'Save', method: :put, data: { confirm: "Are you sure?" }
.field
= link_to 'show', admin_diagnostics_path
显示视图
.field
= label_tag :message
= label_tag @diagnostic.data["message"] || :none
.field
= label_tag :appVersion
= label_tag @diagnostic.data["appVersion"] || :none
.field
= label_tag :device
= label_tag do
%pre= JSON.pretty_generate(@diagnostic.data["device"])
.field
= label_tag :screenshot
- if @diagnostic.data["screenshot"]
= image_tag @diagnostic.data["screenshot"]
- else
= label_tag :none
.field
= label_tag :localStorage
-if @diagnostic.data["localStorage"]
= label_tag do
%pre= JSON.pretty_generate(@diagnostic.data["localStorage"])
= link_to 'Delete', admin_diagnostic_path(@diagnostic), method: :delete, data: { confirm: 'really?' }
= link_to 'Edit', edit_admin_diagnostic_path
错误
Failure/Error: page.should have_content("test notes")
expected to find text "test notes"
【问题讨论】:
标签: ruby-on-rails capybara haml