如何在我的规范文件中包含图像路径?

How do I include image path in my spec file?

当我在 Rails 6.0 上的 Ruby 中的 *_spec.rb 文件中包含图像时出现错误,我正在使用 rspec gem.我绝对是这个框架的初学者,我相信错误与 windows 路径有关。我在 Stack Overflow 中阅读了很多 post,但我还无法解决。我的文件内容是:

require "rails_helper.rb"
RSpec.feature "Admins pueden crear articulos" do
    scenario "con atributos validos" do
        visit "/"
        fill_in "Name", with: "Razones por las cuales aprender Ruby on Rails"
        fill_in "Content", with: "Es un gran lenguaje de programacion"
        attach_file "Main image",'D:/ProyectosPersonales/RubyProjects/blog/spec/images/avatar4.jpg'

        click_button "Guardar"
    end
end

我附上错误的截图:

根据the doc

1) 页面上的某些输入元素应具有名称、ID 或 label_text 匹配 "Main image"

2) 你应该使用文件的相对(不是绝对)路径,在你的情况下 /spec/images/avatar4.jpg

查看 File Fixtures,并将测试图像文件的副本添加到 spec/fixtures/files/images/avatar4.jpg