On 8/13/07, Shaker <[EMAIL PROTECTED]> wrote:
>
> Dear Aslak:
> Sorry to bother you over and over again. I did follow your instruction to
> write the controller spec, but...the thing is not getting better.:-(
> I'd like to post my code again, hopefully you would figure it out.
> My Controller
> class MyController
> def index
> pre = Array.new
> render :partial=>'index', layout=>false, locals=>{:pre=>pre}
> end
> end
> ------------------------------------------------------------
> My Controller spec
> describe MyController do
> it "should render the index partial" do
> controller.expect_render(:partial=>'index', :layout=>false)
> get 'index'
> end
> end
> ------------------------------------------------------------
> By the way, I am using JRuby rather than ruby. Hence my command to run the
> spec above is
> jruby --command spec spec/controllers/my_controller_spec.rb --format specdoc
> It always gave me an error:Mock 'expect_render_mock_proxy' expected :render
> with
> ({:partial=>"index"}) once, but received it 0 times.
> Is it because "expect_render" is not compatible with JRuby or I forgot to
> mock something?
> Thanks a lot.
> Regards.
>
Your failing test case seems to indicate a correct failure. You are expecting:
controller.expect_render(:partial=>'index', :layout=>false)
but you are passing in:
render :partial=>'index', layout=>false, locals=>{:pre=>pre}
Try updating your test to expect the :locals or try removing them from
your call to render, whichever is correct for what you are doing,
Zach
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users