我正在編寫一個功能測試,現在正在嘗試測試編輯操作。這對我來說有點奇怪,因爲它沒有看到我通常運行RSpec時所期望的結果,但是當我使用save_and_open_page命令時,它顯示出我期望的實際上是在瀏覽器中。我認爲這是一個硒問題,但我是rspec新手,我不確定。我被建議使用「睡眠」或「暫停」,但我不確定如何使用這些方法,我找不到任何好的文檔。我想知道如果有人能夠給我一個有效的方式來使用我當前的代碼?調用RSpec睡眠
TEST
require "rails_helper"
RSpec.feature "Edit 'Bounce Back' Message", :type => :feature do
given!(:group) { Group.create!(name: "Group A", response: "You are now subscribed for updates") }
scenario "Staff can see the response messages" do
visit "/groups"
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")
expect(page).to have_content("Group a")
end
scenario "Staff can edit the response messages" do
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 have now subscribed for updates")
end
end
我希望這是足夠的信息,請讓我知道如果你需要更多。謝謝! 我也試過使用rspec_wait,但它仍然發送錯誤。這裏是
<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>
不要睡覺;讓水豚等你。你的例子對我來說很好,他們在哪裏失敗? –