这是我用于创建新帖子的功能规范测试
require 'rails_helper'
require 'ffaker'
RSpec.feature 'Creating posts', :type => :feature do
scenario 'can create a new post' do
visit root_path
click_link 'New Post'
attach_file('Image', FFaker::File.file_name('spec/files', 'foo', 'jpg'))
fill_in 'Caption', with: 'Hello World! This is the first post!'
click_button 'Create Post'
expect(page).to have_content('Post was successfully created')
end
end
当我运行rspec
命令运行测试时,我收到以下错误
Failure/Error: attach_file('Image', FFaker::File.file_name('spec/files', 'foo', 'jpg'))
NameError:
uninitialized constant FFaker::File
我该如何解决这个问题?
基本上我曾尝试使用ffaker
来尝试上传图片而不是使用真实的图片文件。这应该和ffaker合作吗,对吧?