First off, I''m not trying to spec attachment_fu, I know it''s been tested. But, I added some code to that model that I do need to test. Basically, I need to somehow fulfill the "uploaded_data" property so I can actually run my tests(otherwise they fail because of validations). The "uploaded_data" field is what would grab the multipart data from form. Here it is: # This method handles the uploaded file object. If you set the field name to uploaded_data, you don''t need # any special code in your controller. # # <% form_for :attachment, :html => { :multipart => true } do |f| -%> # <p><%= f.file_field :uploaded_data %></p> # <p><%= submit_tag :Save %> # <% end -%> # # @attachment = Attachment.create! params[:attachment] # # TODO: Allow it to work with Merb tempfiles too. def uploaded_data=(file_data) return nil if file_data.nil? || file_data.size == 0 self.content_type = file_data.content_type self.filename = file_data.original_filename if respond_to?(:filename) if file_data.is_a?(StringIO) file_data.rewind self.temp_data = file_data.read else self.temp_path = file_data.path end end While I was digging I found out that "file_data" is a ruby Tempfile object. So, I tried to create a dummy file and pass it, but it failed. I found out in the CGI library, it actually extends the Tempfile object and adds some methods/properties. It started to get messy, so I thought I''d ask for advice. How can I create a valid attachment_fu model spec(so I can start tweaking it to test my other validations)? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070822/c286d77d/attachment.html
On 8/22/07, Matt Lins <mlins at webinforem.com> wrote:> > First off, I''m not trying to spec attachment_fu, I know it''s been tested. > > But, I added some code to that model that I do need to test. Basically, I > need to somehow fulfill the "uploaded_data" property so I can actually run > my tests(otherwise they fail because of validations). The "uploaded_data" > field is what would grab the multipart data from form. Here it is: > > # This method handles the uploaded file object. If you set the field > name to uploaded_data, you don''t need > # any special code in your controller. > # > # <% form_for :attachment, :html => { :multipart => true } do |f| > -%> > # <p><%= f.file_field :uploaded_data %></p> > # <p><%= submit_tag :Save %> > # <% end -%> > # > # @attachment = Attachment.create! params[:attachment] > # > # TODO: Allow it to work with Merb tempfiles too. > def uploaded_data=(file_data) > return nil if file_data.nil? || file_data.size == 0 > self.content_type = file_data.content_type > self.filename = file_data.original_filename if > respond_to?(:filename) > if file_data.is_a?(StringIO) > file_data.rewind > self.temp_data = file_data.read > else > self.temp_path = file_data.path > end > end >I''m not familiar with attachment_fu - is this code from attachment_fu that you have modified? Or is it your code entirely? Attachment_fu''s entirely? Where does this code come from? Aslak> While I was digging I found out that "file_data" is a ruby Tempfile object. > So, I tried to create a dummy file and pass it, but it failed. I found out > in the CGI library, it actually extends the Tempfile object and adds some > methods/properties. It started to get messy, so I thought I''d ask for > advice. > > How can I create a valid attachment_fu model spec(so I can start tweaking > it to test my other validations)? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Sorry, attachment_fu is a plugin for handling binary data. It handles storing the file in the file system and storing some helpful data in the database about the file. The previous code is from the attachment_fu plugin(no, I didn''t modify it). This property needs to be satisfied in order for the model to validate. So I need to get my model to validate in the spec so I can actually test other parts of my model. Here is my model: class Picture < ActiveRecord::Base has_and_belongs_to_many :products has_attachment :content_type => ''image/jpeg'', :storage => :file_system, :max_size => 3.megabytes, :resize_to => ''400x400>'', :thumbnails => {:medium => ''200x200>'', :small => ''100x100>''}, :path_prefix => ''images/products'' validates_as_attachment validates_uniqueness_of :filename validates_presence_of :filename def before_update self.thumbnails.each do |t| t.filename= thumbnail_name_for(t.thumbnail) t.save end end def full_filename(thumbnail = nil) file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s File.join(RAILS_ROOT, ''public/external'', file_system_path, thumbnail_name_for(thumbnail) + ''.jpg'') end def public_image self.public_filename end end aslak hellesoy wrote:> On 8/22/07, Matt Lins <mlins at webinforem.com> wrote: > >> First off, I''m not trying to spec attachment_fu, I know it''s been tested. >> >> But, I added some code to that model that I do need to test. Basically, I >> need to somehow fulfill the "uploaded_data" property so I can actually run >> my tests(otherwise they fail because of validations). The "uploaded_data" >> field is what would grab the multipart data from form. Here it is: >> >> # This method handles the uploaded file object. If you set the field >> name to uploaded_data, you don''t need >> # any special code in your controller. >> # >> # <% form_for :attachment, :html => { :multipart => true } do |f| >> -%> >> # <p><%= f.file_field :uploaded_data %></p> >> # <p><%= submit_tag :Save %> >> # <% end -%> >> # >> # @attachment = Attachment.create! params[:attachment] >> # >> # TODO: Allow it to work with Merb tempfiles too. >> def uploaded_data=(file_data) >> return nil if file_data.nil? || file_data.size == 0 >> self.content_type = file_data.content_type >> self.filename = file_data.original_filename if >> respond_to?(:filename) >> if file_data.is_a?(StringIO) >> file_data.rewind >> self.temp_data = file_data.read >> else >> self.temp_path = file_data.path >> end >> end >> >> > > I''m not familiar with attachment_fu - is this code from attachment_fu > that you have modified? Or is it your code entirely? Attachment_fu''s > entirely? Where does this code come from? > > Aslak > > >> While I was digging I found out that "file_data" is a ruby Tempfile object. >> So, I tried to create a dummy file and pass it, but it failed. I found out >> in the CGI library, it actually extends the Tempfile object and adds some >> methods/properties. It started to get messy, so I thought I''d ask for >> advice. >> >> How can I create a valid attachment_fu model spec(so I can start tweaking >> it to test my other validations)? >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070822/0a557459/attachment-0001.html
On 8/22/07, Matt Lins <mlins at webinforem.com> wrote:> > Sorry, attachment_fu is a plugin for handling binary data. It handles > storing the file in the file system and storing some helpful data in the > database about the file. > > The previous code is from the attachment_fu plugin(no, I didn''t modify > it). This propertyWhat property? The :filename property?> needs to be satisfied in order for the model to validate. > So I need to get my model to validate in the spec so I can actually test > other parts of my model. Here is my model: >Can''t you just set the filename property directly from your spec without going through attachment kung fu? Aslak> class Picture < ActiveRecord::Base > > has_and_belongs_to_many :products > > has_attachment :content_type => ''image/jpeg'', > :storage => :file_system, > :max_size => 3.megabytes, > :resize_to => ''400x400>'', > :thumbnails => {:medium => ''200x200>'', :small => > ''100x100>''}, > :path_prefix => ''images/products'' > > validates_as_attachment > > validates_uniqueness_of :filename > validates_presence_of :filename > > def before_update > self.thumbnails.each do |t| > t.filename= thumbnail_name_for(t.thumbnail) > t.save > end > end > > def full_filename(thumbnail = nil) > file_system_path = (thumbnail ? thumbnail_class : > self).attachment_options[:path_prefix].to_s > File.join(RAILS_ROOT, ''public/external'', file_system_path, > thumbnail_name_for(thumbnail) + ''.jpg'') > end > > def public_image > self.public_filename > end > > end > > > aslak hellesoy wrote: > On 8/22/07, Matt Lins <mlins at webinforem.com> wrote: > > > First off, I''m not trying to spec attachment_fu, I know it''s been tested. > > But, I added some code to that model that I do need to test. Basically, I > need to somehow fulfill the "uploaded_data" property so I can actually run > my tests(otherwise they fail because of validations). The "uploaded_data" > field is what would grab the multipart data from form. Here it is: > > # This method handles the uploaded file object. If you set the field > name to uploaded_data, you don''t need > # any special code in your controller. > # > # <% form_for :attachment, :html => { :multipart => true } do |f| > -%> > # <p><%= f.file_field :uploaded_data %></p> > # <p><%= submit_tag :Save %> > # <% end -%> > # > # @attachment = Attachment.create! params[:attachment] > # > # TODO: Allow it to work with Merb tempfiles too. > def uploaded_data=(file_data) > return nil if file_data.nil? || file_data.size == 0 > self.content_type = file_data.content_type > self.filename = file_data.original_filename if > respond_to?(:filename) > if file_data.is_a?(StringIO) > file_data.rewind > self.temp_data = file_data.read > else > self.temp_path = file_data.path > end > end > > > I''m not familiar with attachment_fu - is this code from attachment_fu > that you have modified? Or is it your code entirely? Attachment_fu''s > entirely? Where does this code come from? > > Aslak > > > > While I was digging I found out that "file_data" is a ruby Tempfile object. > So, I tried to create a dummy file and pass it, but it failed. I found out > in the CGI library, it actually extends the Tempfile object and adds some > methods/properties. It started to get messy, so I thought I''d ask for > advice. > > How can I create a valid attachment_fu model spec(so I can start tweaking > it to test my other validations)? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
I just got finished working with attachment_fu, and ended up modeling a plugin for my company since attachment_fu was slight over kill for our needs. Have you opened up attachment_fu''s source? upload_data is just a method (so is upload_data=) which is inserted into a model that calls has_attachment. I have yet to spec my plugin so I''m interested to see what your results are. Thanks, :: Justin Reagor :: justinwr at gmail.com On Aug 22, 2007, at 12:46 PM, Matt Lins wrote:> Sorry, attachment_fu is a plugin for handling binary data. It > handles storing the file in the file system and storing some > helpful data in the database about the file. > > The previous code is from the attachment_fu plugin(no, I didn''t > modify it). This property needs to be satisfied in order for the > model to validate. So I need to get my model to validate in the > spec so I can actually test other parts of my model. Here is my model: > > class Picture < ActiveRecord::Base > > has_and_belongs_to_many :products > > has_attachment :content_type => ''image/jpeg'', > :storage => :file_system, > :max_size => 3.megabytes, > :resize_to => ''400x400>'', > :thumbnails => {:medium => ''200x200>'', :small => > ''100x100>''}, > :path_prefix => ''images/products'' > > validates_as_attachment > > validates_uniqueness_of :filename > validates_presence_of :filename > > def before_update > self.thumbnails.each do |t| > t.filename= thumbnail_name_for(t.thumbnail) > t.save > end > end > > def full_filename(thumbnail = nil) > file_system_path = (thumbnail ? thumbnail_class : > self).attachment_options[:path_prefix].to_s > File.join(RAILS_ROOT, ''public/external'', file_system_path, > thumbnail_name_for(thumbnail) + ''.jpg'') > end > > def public_image > self.public_filename > end > > end > > aslak hellesoy wrote: >> On 8/22/07, Matt Lins <mlins at webinforem.com> wrote: >> >>> First off, I''m not trying to spec attachment_fu, I know it''s >>> been tested. >>> >>> But, I added some code to that model that I do need to test. >>> Basically, I >>> need to somehow fulfill the "uploaded_data" property so I can >>> actually run >>> my tests(otherwise they fail because of validations). The >>> "uploaded_data" >>> field is what would grab the multipart data from form. Here it is: >>> >>> # This method handles the uploaded file object. If you >>> set the field >>> name to uploaded_data, you don''t need >>> # any special code in your controller. >>> # >>> # <% form_for :attachment, :html => { :multipart => >>> true } do |f| >>> -%> >>> # <p><%= f.file_field :uploaded_data %></p> >>> # <p><%= submit_tag :Save %> >>> # <% end -%> >>> # >>> # @attachment = Attachment.create! params[:attachment] >>> # >>> # TODO: Allow it to work with Merb tempfiles too. >>> def uploaded_data=(file_data) >>> return nil if file_data.nil? || file_data.size == 0 >>> self.content_type = file_data.content_type >>> self.filename = file_data.original_filename if >>> respond_to?(:filename) >>> if file_data.is_a?(StringIO) >>> file_data.rewind >>> self.temp_data = file_data.read >>> else >>> self.temp_path = file_data.path >>> end >>> end >>> >>> >> I''m not familiar with attachment_fu - is this code from attachment_fu >> that you have modified? Or is it your code entirely? Attachment_fu''s >> entirely? Where does this code come from? >> >> Aslak >> >> >>> While I was digging I found out that "file_data" is a ruby >>> Tempfile object. >>> So, I tried to create a dummy file and pass it, but it failed. I >>> found out >>> in the CGI library, it actually extends the Tempfile object and >>> adds some >>> methods/properties. It started to get messy, so I thought I''d ask >>> for >>> advice. >>> >>> How can I create a valid attachment_fu model spec(so I can start >>> tweaking >>> it to test my other validations)? >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070822/6ddf27a6/attachment.html
> # TODO: Allow it to work with Merb tempfiles too. > def uploaded_data=(file_data) > return nil if file_data.nil? || file_data.size == 0 > self.content_type = file_data.content_typeDurh... stupid me, didn''t see this post! :) :: Justin Reagor :: justinwr at gmail.com :: Justin Reagor :: justinwr at gmail.com On Aug 22, 2007, at 12:23 PM, Matt Lins wrote:> First off, I''m not trying to spec attachment_fu, I know it''s been > tested. > > But, I added some code to that model that I do need to test. > Basically, I need to somehow fulfill the "uploaded_data" property > so I can actually run my tests(otherwise they fail because of > validations). The "uploaded_data" field is what would grab the > multipart data from form. Here it is: > > # This method handles the uploaded file object. If you set > the field name to uploaded_data, you don''t need > # any special code in your controller. > # > # <% form_for :attachment, :html => { :multipart => true } > do |f| -%> > # <p><%= f.file_field :uploaded_data %></p> > # <p><%= submit_tag :Save %> > # <% end -%> > # > # @attachment = Attachment.create! params[:attachment] > # > # TODO: Allow it to work with Merb tempfiles too. > def uploaded_data=(file_data) > return nil if file_data.nil? || file_data.size == 0 > self.content_type = file_data.content_type > self.filename = file_data.original_filename if > respond_to?(:filename) > if file_data.is_a?(StringIO) > file_data.rewind > self.temp_data = file_data.read > else > self.temp_path = file_data.path > end > end > > While I was digging I found out that "file_data" is a ruby Tempfile > object. So, I tried to create a dummy file and pass it, but it > failed. I found out in the CGI library, it actually extends the > Tempfile object and adds some methods/properties. It started to get > messy, so I thought I''d ask for advice. > > How can I create a valid attachment_fu model spec(so I can start > tweaking it to test my other validations)? > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070822/d55178a9/attachment-0001.html
No, as mentioned in my first post, the property that needs to be fulfilled is uploaded_data. I posted the accessor in my first post as well. aslak hellesoy wrote:> On 8/22/07, Matt Lins <mlins at webinforem.com> wrote: > >> Sorry, attachment_fu is a plugin for handling binary data. It handles >> storing the file in the file system and storing some helpful data in the >> database about the file. >> >> The previous code is from the attachment_fu plugin(no, I didn''t modify >> it). This property >> > > What property? The :filename property? > > >> needs to be satisfied in order for the model to validate. >> So I need to get my model to validate in the spec so I can actually test >> other parts of my model. Here is my model: >> >> > > Can''t you just set the filename property directly from your spec > without going through attachment kung fu? > > Aslak > > >> class Picture < ActiveRecord::Base >> >> has_and_belongs_to_many :products >> >> has_attachment :content_type => ''image/jpeg'', >> :storage => :file_system, >> :max_size => 3.megabytes, >> :resize_to => ''400x400>'', >> :thumbnails => {:medium => ''200x200>'', :small => >> ''100x100>''}, >> :path_prefix => ''images/products'' >> >> validates_as_attachment >> >> validates_uniqueness_of :filename >> validates_presence_of :filename >> >> def before_update >> self.thumbnails.each do |t| >> t.filename= thumbnail_name_for(t.thumbnail) >> t.save >> end >> end >> >> def full_filename(thumbnail = nil) >> file_system_path = (thumbnail ? thumbnail_class : >> self).attachment_options[:path_prefix].to_s >> File.join(RAILS_ROOT, ''public/external'', file_system_path, >> thumbnail_name_for(thumbnail) + ''.jpg'') >> end >> >> def public_image >> self.public_filename >> end >> >> end >> >> >> aslak hellesoy wrote: >> On 8/22/07, Matt Lins <mlins at webinforem.com> wrote: >> >> >> First off, I''m not trying to spec attachment_fu, I know it''s been tested. >> >> But, I added some code to that model that I do need to test. Basically, I >> need to somehow fulfill the "uploaded_data" property so I can actually run >> my tests(otherwise they fail because of validations). The "uploaded_data" >> field is what would grab the multipart data from form. Here it is: >> >> # This method handles the uploaded file object. If you set the field >> name to uploaded_data, you don''t need >> # any special code in your controller. >> # >> # <% form_for :attachment, :html => { :multipart => true } do |f| >> -%> >> # <p><%= f.file_field :uploaded_data %></p> >> # <p><%= submit_tag :Save %> >> # <% end -%> >> # >> # @attachment = Attachment.create! params[:attachment] >> # >> # TODO: Allow it to work with Merb tempfiles too. >> def uploaded_data=(file_data) >> return nil if file_data.nil? || file_data.size == 0 >> self.content_type = file_data.content_type >> self.filename = file_data.original_filename if >> respond_to?(:filename) >> if file_data.is_a?(StringIO) >> file_data.rewind >> self.temp_data = file_data.read >> else >> self.temp_path = file_data.path >> end >> end >> >> >> I''m not familiar with attachment_fu - is this code from attachment_fu >> that you have modified? Or is it your code entirely? Attachment_fu''s >> entirely? Where does this code come from? >> >> Aslak >> >> >> >> While I was digging I found out that "file_data" is a ruby Tempfile object. >> So, I tried to create a dummy file and pass it, but it failed. I found out >> in the CGI library, it actually extends the Tempfile object and adds some >> methods/properties. It started to get messy, so I thought I''d ask for >> advice. >> >> How can I create a valid attachment_fu model spec(so I can start tweaking >> it to test my other validations)? >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070822/59e27f77/attachment.html
On 8/22/07, Matt Lins <mlins at webinforem.com> wrote:> > No, as mentioned in my first post, the property that needs to be fulfilled > is uploaded_data. I posted the accessor in my first post as well. >Which part of my answer are you answering no to? Can you inline your answers so I can follow?> > aslak hellesoy wrote: > On 8/22/07, Matt Lins <mlins at webinforem.com> wrote: > > > Sorry, attachment_fu is a plugin for handling binary data. It handles > storing the file in the file system and storing some helpful data in the > database about the file. > > The previous code is from the attachment_fu plugin(no, I didn''t modify > it). This property > > What property? The :filename property? > > > > needs to be satisfied in order for the model to validate. > So I need to get my model to validate in the spec so I can actually test > other parts of my model. Here is my model: > > > Can''t you just set the filename property directly from your spec > without going through attachment kung fu? > > Aslak > > > > class Picture < ActiveRecord::Base > > has_and_belongs_to_many :products > > has_attachment :content_type => ''image/jpeg'', > :storage => :file_system, > :max_size => 3.megabytes, > :resize_to => ''400x400>'', > :thumbnails => {:medium => ''200x200>'', :small => > ''100x100>''}, > :path_prefix => ''images/products'' > > validates_as_attachment > > validates_uniqueness_of :filename > validates_presence_of :filename > > def before_update > self.thumbnails.each do |t| > t.filename= thumbnail_name_for(t.thumbnail) > t.save > end > end > > def full_filename(thumbnail = nil) > file_system_path = (thumbnail ? thumbnail_class : > self).attachment_options[:path_prefix].to_s > File.join(RAILS_ROOT, ''public/external'', file_system_path, > thumbnail_name_for(thumbnail) + ''.jpg'') > end > > def public_image > self.public_filename > end > > end > > > aslak hellesoy wrote: > On 8/22/07, Matt Lins <mlins at webinforem.com> wrote: > > > First off, I''m not trying to spec attachment_fu, I know it''s been tested. > > But, I added some code to that model that I do need to test. Basically, I > need to somehow fulfill the "uploaded_data" property so I can actually run > my tests(otherwise they fail because of validations). The "uploaded_data" > field is what would grab the multipart data from form. Here it is: > > # This method handles the uploaded file object. If you set the field > name to uploaded_data, you don''t need > # any special code in your controller. > # > # <% form_for :attachment, :html => { :multipart => true } do |f| > -%> > # <p><%= f.file_field :uploaded_data %></p> > # <p><%= submit_tag :Save %> > # <% end -%> > # > # @attachment = Attachment.create! params[:attachment] > # > # TODO: Allow it to work with Merb tempfiles too. > def uploaded_data=(file_data) > return nil if file_data.nil? || file_data.size == 0 > self.content_type = file_data.content_type > self.filename = file_data.original_filename if > respond_to?(:filename) > if file_data.is_a?(StringIO) > file_data.rewind > self.temp_data = file_data.read > else > self.temp_path = file_data.path > end > end > > > I''m not familiar with attachment_fu - is this code from attachment_fu > that you have modified? Or is it your code entirely? Attachment_fu''s > entirely? Where does this code come from? > > Aslak > > > > While I was digging I found out that "file_data" is a ruby Tempfile object. > So, I tried to create a dummy file and pass it, but it failed. I found out > in the CGI library, it actually extends the Tempfile object and adds some > methods/properties. It started to get messy, so I thought I''d ask for > advice. > > How can I create a valid attachment_fu model spec(so I can start tweaking > it to test my other validations)? > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
I think you need to clarify what you mean by ''spec an attachment_fu model''. Do you want the validates_as_attachment to succeed with your test data, for instance? If so, simply stub the call: Picture.should_receive(:validates_as_attachment) so that you can be confident the model does the right thing (ensuring it is validated in real life) but the real validation code is never called and so never added to the validation chain, so your test models will save without hassle. I think that''s the gist of your problem - you can''t get test model instances to validate and so cannot write meaningful tests? Alternatively you may have to include your failing specs so we can understand your situation more clearly. Best wishes, Jerry