我有一個功能測試試圖驗證編輯操作。這是一個超級簡單的測試,但我沒有寫很多,我犯了一些我弄不明白的錯誤。基本上,當頁面被訪問時,它不會呈現要編輯的文本信息,並且「更新」按鈕不存在。這是我的錯誤和代碼清晰。Rspec功能測試混淆
TEST
scenario "Staff can edit the response messages" do
group = Group.create!(name: "Group A", response: "You are now subscribed for updates")
visit "/groups/#{group.id}/edit"
user = FactoryGirl.create(:user)
fill_in "Email", with: user.email
fill_in "Password", with: user.password
click_button "Sign in"
expect(page).to have_content("You are now subscribed for updates")
end
VIEW
<div class="container text-center">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 well">
<%= form_for @group do |form| %>
<div class="form-group">
<%= form.label :body, "Edit The Response:", class: "message_label"%>
<%= form.text_field :response, class: "form-control", placeholder: "New things are happening!" %>
</div>
<%= form.submit "Update", class: "btn btn-primary" %>
<% end %>
</div>
</div>
</div>
當我運行 「save_and_open_page」 我期待的內容存在更令人奇怪的是什麼嗎?但是,我的測試仍然失敗,說預期的內容不顯示WEIRD!
您好的
例。在你看來,我沒有看到你再次測試的文本應該顯示在哪裏。帶有失敗消息的圖像不會顯示頁面上實際存在的所有文本(它的右側截斷)通常,我建議使用save_and_open_page或save_and_open_screenshot(如果您的包中有capybara-screenshot)更好地瞭解頁面實際顯示的內容。 – trueunlessfalse
是的,這更奇怪,因爲如果我使用save_and_open_page,它顯示了我期望在頁面上的內容,但是如果我運行測試它不會顯示出來? – Cambass
唱完後只插入'暫停3'僅供測試使用 –