I got the spec and controller minimally working now, here's the code
paste for both in full.

http://pastie.caboo.se/165743

still working on it, any suggestions on possible improvements would be
greatly appreciated.

2008/3/14, Oliver Barnes <[EMAIL PROTECTED]>:
> thanks, will do - I am still wrapping my mind around mocks and stubs indeed :)
>
>
>  2008/3/13, Pat Maddox <[EMAIL PROTECTED]>:
>
> > On Thu, Mar 13, 2008 at 4:55 PM, Oliver Barnes
>  >
>  > <[EMAIL PROTECTED]> wrote:
>  >
>  > > I see. I had gotten to trying the first way you suggested (haven't
>  >  >  tried the second yet):
>  >  >
>  >  >       it "should assign an image to the work" do
>  >  >        @work.should_receive(:image=).with(@image)
>  >  >       end
>  >  >
>  >  >  but I got the following error:
>  >  >
>  >  >  should assign an image to the work
>  >  >  Mock 'Work_1002' expected :image= with (#<Image:0x19e8094
>  >  >  @name="Image_1001">) once, but received it 0 times
>  >  >
>  >  >  though in the actual controller @work does receive it:
>  >  >
>  >  >   def create
>  >  >     @work = @category.works.build(params[:work])
>  >  >     @image = Image.new(params[:image])
>  >  >     @work.image = @image
>  >  >     respond_to do |format|
>  >  >       if @image.save and @work.save
>  >  >         flash[:notice] = 'Work was successfully created.'
>  >  >         format.html { redirect_to 
> admin_category_work_path(@category,@work) }
>  >  >       else
>  >  >         format.html { render :action => "new" }
>  >  >       end
>  >  >     end
>  >  >   end
>  >  >
>  >  >  I'm sure I'm missing something here...
>  >
>  >
>  > In all likelihood, you're not stubbing the call to
>  >  @category.works.build, and instead are just letting Rails do its
>  >  thing.  You need to take control of the objects if you want to make
>  >  interaction verifications of them.
>  >
>  >  Read through some of the documentation starting at
>  >  http://rspec.info/documentation/mocks/ and see if you can grok it.
>  >  Feel free to ask more questions if you run into trouble.
>  >
>  >
>  >  Pat
>  >  _______________________________________________
>  >  rspec-users mailing list
>  >  rspec-users@rubyforge.org
>  >  http://rubyforge.org/mailman/listinfo/rspec-users
>  >
>
>
>
> --
>  Oliver Azevedo Barnes
>
> [EMAIL PROTECTED]
>
> +55 11 9768 0193
>  http://www.linkedin.com/in/oliverbarnes
>  http://workingwithrails.com/person/4704-oliver-barnes
>


-- 
Oliver Azevedo Barnes
[EMAIL PROTECTED]
+55 11 9768 0193
http://www.linkedin.com/in/oliverbarnes
http://workingwithrails.com/person/4704-oliver-barnes
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to