Hello!
I wonder if it’s possible to simulate Paperclip’s has_attached_file
with Factory Girl and then test it with Rspec. I don’t get it to work.
My factories.rb file looks like this:
Factory.define :user do |user|
user.name “Anders”
user.email “[email protected]”
user.password “foobar”
user.password_confirmation “foobar”
user.avatar_file_name “avatar”
end
My Rspec test (users_controller_spec.rb) looks like this:
it “should have a profile image” do
get :show, :id => @user
should have_attached_file(:avatar)
end
And I get the following error:
UsersController GET ‘show’ should have a profile image
Failure/Error: @user = Factory(:user)
undefined method `avatar_file_name=’ for #User:0x000001037cc550
I have followed these instructions,
GitHub - thoughtbot/paperclip: Easy file attachment management for ActiveRecord.
Any help would be greatly appreciated! I’m a newbie to Rails so it may
be something simple.
Thanks!
// Anders