What to test for views?

When you guys test views, what are you testing? Do you just test that
all the form fields exist in a new.rhtml, that all form fields are
filled in an edit.rhtml, and that all the proper columns are are shown
in a index.rhtml page, or is there something more that should be tested?

Thanks.

I think what David said before about spec views is take it with a grain
of
salt.
If you think you need to check the presence of every field go ahead.

When I spec out my views I only spec what needs to be there:

I won’t check for the presence of a form fields new.rhtml_spec.rb
I would place my fields in a partial called fields and I spec their
presence
in _fields.html_spec.rb
I would spec in my new.rhtml_spec.rb if the partial fields was rendered.

It may satisfy you just to have a spec that says:

it “should show form” do
response.shouldhave_tag(“form[action=#{projects_path(@game)}][method=post]”)
end

Its all up to you how granular you want to get.

I first started to check things existence in the resulting page but
quickly decided to only check for permission-affected links, forms,
etc. Though if your applications are RESTful it would be good idea to
check http method form uses and hidden fields that Rails uses to
piggyback PUT and DELETE on top of POST.

On 9 дек. 2007, at 22:58, Chris O. wrote:

When you guys test views, what are you testing? Do you just test that
all the form fields exist in a new.rhtml, that all form fields are
filled in an edit.rhtml, and that all the proper columns are are shown
in a index.rhtml page, or is there something more that should be
tested?

MK