2009/5/24 Fernando Perez <[email protected]>:
> So I tried to implement Django's AutoAdmin, but actually it quite
> quickly blew in my face. Although the views all look similar, there
> almost as many little differences as they are models and that's painful
> to abstract. So I prefer to write my views for each model.
>
> Now I have another problem, so my models are fully covered, my
> controllers too, but what prevents my views from having for instance an
> incorrect form that would be posting incorrect parameters to my
> controllers? How do you test that? Cucumber + Webrat?
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
I use a combination of convention and cucumber stories using tables.
Convention sets up how a resource will be rendered in the various admin
views. I use classes and a forked version of webrat to detect them. So my
structure will be (using HAML)
index
.resources
# table headers
.resource
tr.fieldname0
tr.fieldname1
show
.resource
ul
li.fieldname
...
Then I test this using cucumber tables e.g
Scenario Outline: Admin can view resources
Given there are 3 <object>
When I goto admin_<collection>
Then I should see a list of <object>
Examples:
| collection | object |
| categories | category |
| customers | customer |
| feeds | feed |
I extend this approach to access. It might be feasible in some way with
editing and creation, but I haven't tried that yet.
This approach obviously doesn't scale to more than about 10 admin resources,
so whilst it will do for now if anyone has any better ideas ... :)
HTH
Andrew
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users