Can you post some code from your Functional test? Based on what
you''ve typed it sounds like your trying to run Unit/Model assertions
during a Functional test, which is something you should try to stay
away from.
Functional tests are how you verify that the "application logic" in
your controller actions is doing the right thing, returning the
proper templates/redirects, and rendering the proper tags in your
XHTML. Running an assertion on a model object is testing "business
logic", which is what your Unit tests are for. That doesn''t mean
you
can''t do a model assertion in a functional test, just that doing so
would be the "wrong place" for that kind of assertion, based on
everything I''ve seen/read about testing in Rails.
-Brian
On May 31, 2006, at 01:22 PM, Ara Vartanian wrote:> I had a beginner''s question. I am testing the create action on my
> controller. I wanted to fetch the ID parameter of the newly created
> object, so that I can make some assertions on it.
>
> But I can''t seem to find an elegant way of doing that. Of course,
> might
> create action redirects. That means that @response.redirect_url is
> something like "/show/8". So I could pluck the number off that,
but
> that
> seems too brittle, since if I change my routing, that would no longer
> work. I was wondering if there was a way to call routing on the
> redirect_url, so that I could then fetch the ID from the parameters
> hash. That wouldn''t be brittle at all. But I can''t seem
to find any
> documentation for routing, and peeking into the class, I''m not
sure
> what
> the entry points are.
>
> perhaps there''s a much easier way of doing all this.