[rspec-users] can't seem to test redirect?

Harry Bishop lists at ruby-forum.com
Fri Oct 24 16:57:47 EDT 2008

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 "#{@motion.id}"
    response.should redirect_to(@motion)

with result:

undefined method `spec_mocks_mock_url' for 

If I change the first line to
@motion = motions(:four)

the result is:

private method `split' called for #<Motion:0x2259944>.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list