On Jan 24, 2008 2:25 AM, Neil M. Young <[EMAIL PROTECTED]> wrote:
>
> some interesting viewpoints so far. How do people feel about something like
> this:
>
> Given every type of user
> When they visit account/manage
> Then only Admins and Managers should get access
>
> Given("every type of user") do
>   @users = {
>     :admin => new_admin,
>     :manager => new_manager,
>     :supervisor => new_supervisor,
>     :reviewer => new_reviewer,
>     :user => new_user
> }
> end
>
> When("they visit $url") do |url|
>   @url = url
> end
>
> Then("only $allow_list should get access") do |allow_list|
>   allow_list = allow_list.split(' and ').collect {|x|
> x.downcase.singularize.intern}
>   allow_list.each do |x|
>     user = @users.delete(x)
>     # log user in
>     get @url
>     response.should_not be_redirect
>   end
>   @users.each do |x|
>     #log user in
>     get @url
>     response.should redirect_to("not_authorised")
>   end
> end
>
> any major BDD violations there? I personally don't mind the somewhat complex
> steps because as Ben pointed out, the plain text stories are more manageable
> this way and still very readable.

I think I'd rather have the first step be explicit about the different types:

Given users in the Manager, Admin, Supervisor and Anonymous roles
When they visit account/manage
Then only Admins and Managers should get access

As for the complexity within the steps, there's a balance to be found
between that and clarity of the steps in the scenario (Given blah de
blah). The underlying principle should be that you or anyone on your
team should be able to quickly understand a failure. As soon as you
start debugging steps to understand a failure, those steps are losing
part of their value.

Where that leads you is going to vary from person to person, team to
team. For me, personally, my only beef with the Then step definition
here is that I wouldn't likely be able to know which role caused the
failure. Otherwise I don't feel there is a fundamental BDD violation.

FWIW,
Cheers,
David


>
>
> Neil M. Young wrote:
> >
> > I'm finding that I'm writing sets of very similar scenarios to check
> > access permissions for each of my actions.
> >
> > snip
> >
>
> --
> View this message in context: 
> http://www.nabble.com/DRYing-up-stories-tp15053384p15060580.html
>
> Sent from the rspec-users mailing list archive at Nabble.com.
>
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to