Using: RSpec, Shoulda, Paperclip (including matchers) Example Model
class Example < ActiveRecord::Base has_attached_file :attachment validates_attachment_presence :attachment validates_format_of :attachment_file_name, :with => /\.(png|jpe?g)$/ end Example Test require 'spec/helper' describe Example do it { should validate_attachment_presence(:attachment) } it { should validate_format_of(:attachment_file_name). with('example.png') } it { should validate_format_of(:attachment_file_name). not_with('example.zip'). with_message(/is invalid/) } end This causes my validates_attachment_presence(:attachment) test to fail. If I remove the validates_format_of :attachment_file_name line from my model, the presence test now passes, but, obviously, the format test fails. I noticed that basically all validates_attachment_presence does is require attachment_file_name, but I can't seem to find any reason why it affects my format tests. I am not sure if this is necessarily Paperclip issue (as apposed to perhaps a Shoulda one), but hopefully this is a good enough report to explain the issue. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.