1

I had a set of Rspec User Model tests that were passing, until I had the paperclip attribute "profile picture".

Everything is fine with paperclip, it works great, but I would like my tests also to be updated to pass. I just added this line to the @attr of the user_spec file:

:avatar => File.new (Rails.root + "public/images/Default_profile_picture.jpg") 

in a before_each loop that creates a standard set of working attribute for the user model.

When I run the tests, ALL the tests give me the error message:

User model missing required attr_accessor for 'avatar_file_name' ... 

Putting paperclip's fields as attr_accessor in the model makes the problem disappear in the test, but I don't think I should do this in my model (it does not work properly if I do).

Does anyone has an idea why I got these error messages when testing ? ... (I included the config line Shoulda::Matchers and the require paperclip lines in the spec/helper)

Thanks for any answer you may post !

1 Answer 1

8

It was simply that I forgot to run

rake db:test:prepare 

before running my tests :-/

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.