这是我正在尝试运行的功能规范。 Capybara似乎忽略了字体真棒图标......在我的索引中,管理员可以通过单击垃圾桶图标删除任何视频。非常感谢帮助
我正在测试的索引
<%= link_to video_path(video), method: :delete, data: {confirm: "Are you sure?"} do %>
<i class="fas fa-trash-alt trash"></i>
<% end %>
Rspec测试为红色
scenario "delete a video" do
video_1 = Video.create(url: "https://www.youtube.com/watch?v=oWYKTiqPvYA&tg")
video_2 = Video.create(url: "https://www.youtube.com/watch?v=UxIPVAPRBi4")
visit videos_path
first(:link, '.i.fas.fa-trash-alt.trash').click
expect(page).to have_content("Video was successfully destroyed")
end
如果我在i
标签之间添加文本删除:<i class="fas fa-trash-alt trash">delete</i>
Rspec测试是绿色的
scenario "delete a video" do
video_1 = Video.create(url: "https://www.youtube.com/watch?v=oWYKTiqPvYA&t")
video_2 = Video.create(url: "https://www.youtube.com/watch?v=UxIPVAPRBi4")
visit videos_path
first(:link, 'delete').click
expect(page).to have_content("Video was successfully destroyed")
end
我使用过save_and_open_page
并且没有出现图标
终于找到了解决方案:我在link_to中添加了一个类
<%= link_to video_path(video), method: :delete, data: {confirm: "Are you sure?"}, class: "delete_link" do %>
<i class="fas fa-trash-alt trash"></i>
<% end %>
这样它就是绿色:
scenario "delete a video" do
video_1 = Video.create(url: "https://www.youtube.com/watch?v=Yozj4ZB98Gg")
video_2 = Video.create(url: "https://www.youtube.com/watch?v=UxIPVAPRBi4")
visit videos_path
first(:css, ".delete_link").click
expect(page).to have_content("Video was successfully destroyed")
end