[rspec-users] should_redirect_to in rspec-0.8.0 / rspec_on_rails 1453
s.ross
cwdinfo at gmail.com
Thu Feb 1 17:22:21 EST 2007
I changed it to:
response.should_redirect_to
and it worked. I'm most interested in whether, given a set of
circumstances, a particular redirection happens, so I think it has to
go after the post.
I'm not certain how controller.should_redirect_to would answer this
question.
Thoughts?
On Feb 1, 2007, at 1:20 PM, Robert Martin wrote:
> The "should-redirect-to" has to be called before the 'post'. I
> think it's setting up a mock.
> On Feb 1, 2007, at 1:23 PM, s.ross wrote:
>
>> I have a spec:
>>
>> specify "a post with no user id should add a record" do
>> post :edit_or_create, :user => {:login => 'joeschmoe', :email =>
>> 'joe at shmoe.com', :email_confirmation => 'joe at shmoe.com', :full_name
>> => 'Joe Schmoe'}
>> assigns[:user].should_not_be_nil
>> assigns[:user].new_record?.should_not_be(true)
>> flash[:notice].should_match(/user added/)
>> response.should_be_redirect
>> puts "redirecting to #{response.redirect_url}"
>> puts "this response was #{response.redirect?}"
>> controller.should_redirect_to 'http://test.host/user'
>> end
>>
>> the puts statements output the following:
>>
>> redirecting to http://test.host/user
>> this response was true
>>
>> Any idea why this line:
>>
>> controller.should_redirect_to 'http://test.host/user'
>>
>> would fail with the message:
>>
>> 'Given a UserController edit a post with no user id should add a
>> record' FAILED
>> controller expected call to redirect_to "http://test.host/user" but
>> it was never received
>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
>
> ----
> Robert C. Martin (Uncle Bob) | email: unclebob at objectmentor.com
> Object Mentor Inc. | blog: www.butunclebob.com
> The Agile Transition Experts | web: www.objectmentor.com
> 800-338-6716 |
>
>
>
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20070201/310da6fa/attachment.html
More information about the rspec-users
mailing list