[rspec-users] DRYing up stories

Neil M. Young ermok at tiscali.co.uk
Thu Jan 24 03:25:35 EST 2008

some interesting viewpoints so far. How do people feel about something like

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

When("they visit $url") do |url|
  @url = url

Then("only $allow_list should get access") do |allow_list|
  allow_list = allow_list.split(' and ').collect {|x|
  allow_list.each do |x| 
    user = @users.delete(x)
    # log user in
    get @url
    response.should_not be_redirect
  @users.each do |x|
    #log user in
    get @url
    response.should redirect_to("not_authorised")

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. 

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.

More information about the rspec-users mailing list