我正在编写一个功能测试,现在正在尝试测试编辑操作。这对我来说有点奇怪,因为它没有看到我通常运行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>
不要睡觉;让水豚等你。你的例子对我来说很好,他们在哪里失败? –