[rspec-users] testing an action which requires picture

Mano ah lists at ruby-forum.com
Thu Nov 13 07:48:15 EST 2008


Ramon Tayag wrote:
> I suggest doing those tests in the model, not in the controller.  Just
> do that fixture thing for the controller spec to pass.  But pass the
> same thing in the model.  Here's a sample of how I do it
> 
> require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
> 
> describe ProductImage do
>   before(:all) do
>     @valid_attributes = {
>       :uploaded_data => fixture_file_upload("100x100.jpg",'image/jpg'),
>       :product_id => 1
>     }
>     @product_image = ProductImage.create(@valid_attributes)
>   end
> 
>   it "should create a new instance given valid attributes" do
>     ProductImage.create!(@valid_attributes)
>   end
> end
> 
> Ramon Tayag


Can I know what the create action handle.

I am getting undefined method 'create' error

-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list