This is my feature spec test for creating a new post
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
When I run the rspec command to run the test I get the following error
Failure/Error: attach_file('Image', FFaker::File.file_name('spec/files', 'foo', 'jpg'))
NameError:
uninitialized constant FFaker::File
How can I fix this?
Basically I htought to use ffaker for trying to upload an image instead of using a real image file. Is this supposed to work with ffaker, right?
Aucun commentaire:
Enregistrer un commentaire