Harry Bishop wrote: > Pat Maddox wrote: > >> >> So there are two points you need to address right now: >> * How do you want this action to behave? (success or redirect?) >> * Don't stub behavior that you want to verify (if you want it to >> redirect, let it redirect) >> >> Pat > > Hi Pat, > I am new to rspec and still trying to figure out testing the > controller. I'm not finding it straightforward for me since my app is > built and I am catching up with rspec. I had done unit and functional > testing with TestCase. But I found the individual tests awkward. > > So, I constructed this example to get the create action called and a > successful response (200). That worked. The next part of the create > action on a successful @motion save is to redirect back to show the > motion. > How do I test this redirect action? > > When I take out the stub for redirect I get the following error: > > undefined method `spec_mocks_mocks_url' for > #<MotionsController:0x22604ec> > > Harry
I have the following example: it "once motion is saved render it with show" do @motion = mock(motions(:four)) puts "[EMAIL PROTECTED]" Motion.stub!(:new).and_return(@motion) @motion.stub!(:save).and_return(@motion) do_post response.should redirect_to(@motion) with result: undefined method `spec_mocks_mock_url' for #<MotionsController:0x225cba8> If I change the first line to @motion = motions(:four) the result is: private method `split' called for #<Motion:0x2259944>. Harry -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users