On Tue, Jan 6, 2009 at 9:53 AM, Matt Darby <[email protected]> wrote:
> I'm stumped. How would I go about specing the "update_sandbox" method?
> # bids_controller:
> def new
> @bid = Bid.new
>
> respond_to do |wants|
> wants.html { redirect_to job_bids_path(@job) }
> wants.js {
> update_sandbox do
> render_to_string :partial => 'new', :locals => {:bid => @bid, :job
> => @job}
> end
> }
> end
> end
>
> Here is my 4789th stab at it:
> # bids_controller_spec.rb
> it "should render new template" do
> sandbox = mock("Sandbox")
> controller.stub!(:update_sandbox).and_return(sandbox)
> sandbox.stub!(:render_to_string).with(:partial => 'new', :locals =>
> {:bid => @bid, :job => @job})
>
> sandbox.should_receive(:render_to_string).with(:partial => 'new',
> :locals => {:bid => @bid, :job => @job})
> controller.should_receive(:update_sandbox)
I'm just guessing here, because I don't know what #update_sandbox
does, but you probably want this to yield the sandbox:
controller.should_receive(:update_sandbox).and_yield(sandbox)
Let us know if that works.
Cheers,
David
>
> xhr :get, :new
> end
> # => Mock 'Sandbox' expected :render_to_string with ({:partial=>"new",
> :locals=>{:job=>#<Job:0x2b497e8 @name="Job_1014">, :bid=>#<Bid:0x2b46f0c
> @name="Bid_1015">}}) once, but received it 0 times
> Any pointers would be greatly appreciated!
>
>
> Thanks!
> Matt Darby, M.S.
> Rails | PHP | Linux | MySQL | IT
> Email: matt /\at/\ matt-darby.com
> Skype: matt-darby
> Web: http://blog.matt-darby.com
>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users