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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 19, '12 at 9:04a
activeJan 19, '12 at 9:04a
posts1
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Aashish Kiran: 1 post

People

Translate

site design / logo © 2021 Grokbase