On Fri, Aug 29, 2008 at 1:37 PM, Bart Zonneveld <[EMAIL PROTECTED]> wrote:
> Hey list,
>
> This is a kinda quirky
It's only quirky-ish.
> question for this list, but I do think it belongs
> here. I'm currently writing an app with users with different roles. Roles
> are sequentially so to speak, so role 2 can do everything role 1 can, and so
> on.
> If I truly test my whole app, I should test all behaviour for each role, I
> guess. I could solve that by doing some clever shared steps and all, but my
> main question is this: should I test the behaviour of my entire app for each
> role, or not, since that behaviour is embedded in the app itself?
>From a testing perspective, you should test as much as you need to
feel confident your app works.
>From a refactoring perspective, you should test as much as you need to
feel confident refactoring.
>From a BDD perspective, the roles and permissions shouldn't exist
until there are automated scenarios and code examples driving them
into existence.
The problem of multiple roles * multiple permissions (per role) can
make this explode quite a bit. There is a relatively new feature in
cucumber that lets you express things in a tabular format in addition
to scenarios (think FIT, but plain text). So you can do this:
Scenario: roles 3 and up can create a user
Given I am in the 'role 3' role
When I try to create a new user
Then I am allowed
| role | action | response |
| role 1 | create a new user | denied |
| role 2 | create a new user | denied |
| role 3 | create a new user | allowed |
| role 4 | create a new user | allowed |
| role 5 | create a new user | allowed |
(that looks right if you view in a monospace font)
For my money (even thought it's free), this is the perfect situation
for this format, as it allows you to express a number of cases/rules
in a clear succinct way.
HTH,
David
> thanks a bunch,
> bartz
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users