Living and learning ! Cheers for that David! Cheers! sinclair
On 9/28/07, David Chelimsky <[EMAIL PROTECTED]> wrote: > > On 9/28/07, sinclair bain <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I have the following example: > > > > > > it 'should have a form with an action attribute' do > > response.should have_tag( "form[action=?]", > > '/users/1/machines/1/trouble_tickets') > > end > > for a form like so: > > > > > > <% form_for( :trouble_ticket, > > :url => { :action => 'create', > > :user_id => @machine.current_owner, > > :machine_id => @machine } ) do |f| %> > > When you do this (:machine_id => @machine), rails calls > @machine.to_param. So as long as you're stubbing the to_param method, > it should work. > > Also, if you use mock_model, this is stubbed for you. > > Cheers, > David > > > ... > > > > Now this fails. > > > > The way it will pass is to change the url parameters to _explicitly_ > call > > the id method on the > > parameter values like so: > > > > > > <% form_for( :trouble_ticket, > > :url => { :action => 'create', > > :user_id => @ machine.current_owner.id, > > :machine_id => @machine.id } ) do |f| %> > > ... > > > > (nb. I am stubbing and mock these objects ) > > > > My thought is that rails does not require this since it helps by making > sure > > the #id of each object is used in the action url. > > > > > > Is this an error in rspec or just something (mildly inconsistent? ) > which > > I'll have to do in this very limited context ? > > > > Cheers! > > sinclair > > > > > > > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users@rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users