On 7/28/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 7/28/07, Daniel N <[EMAIL PROTECTED]> wrote: > > I'm trying to specify that an action should be rendered with a given > layout > > one particular spec. > > > > What I've got at the moment is this. > > > > it "should render with the grabber layout" do > > controller.should_receive( :render ).with( :layout => "my_layout" ) > > do_get > > end > > > > This doesnt work even though this call to render is being executed. > > > > render :layout => "my_layout" > > > > Firstly I don't understand why this isn't working. I'm getting an > object > > inspect with this message at the end > > > > > expected :render with ({:layout=>"my_layout"}) but received it with > (no > > args) > > > > > > > I'd really like to understand why this isn't working, but I don't really > > like it anyway. I mean, I really want to spec that under a particular > set > > of conditions it renders with a given layout. > > > > I can't imagine I'm the first person to come up against this one. How > are > > other people handling this? > > I'm not sure what the particular problem is in your case, but there > have been myriad problems with mocking render because render calls > itself recursively and is a one-stop shop for rendering all sorts of > things. RSpec's mock frameworks, as is the case with most mock > frameworks (the one exception I know of being the new RR framework - > see http://rubyforge.org/projects/pivotalrb/) do not support mocking > one call to a method and passing the rest through. So while under some > circumstances everything works fine, under others, not so much. > > This is resolved in trunk with the addition of the expect_render > method, which uses composition to interact with a mock, but doesn't > actually mock the method directly. You use it like this: > > controller.expect_render(:layout => false) > > Any calls to render that don't look like that will be passed through > to the controller's render method. > > This will be part of the 1.0.6 release, which has been on hold for a > few weeks pending some additional changes but I'm thinking of > releasing it sooner than later. > > > > > > Cheers > > Daniel > >
Thanx David. I just updated to trunk and it worked a treat.
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users