水豚找不到字体真棒图标

时间:2018-09-10 12:15:26

标签: ruby-on-rails rspec ruby-on-rails-5 font-awesome

这是我要运行的功能规格。 似乎水豚会忽略字体真棒图标... 在我的索引中,管理员可以通过单击垃圾桶图标删除所有视频。 帮助将不胜感激

我正在测试的索引

    <%= 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标签之间添加文本 delete <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并且图标没有出现

1 个答案:

答案 0 :(得分:0)

最终找到了解决方案: 我在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