[rspec-users] DRYing up stories

David Chelimsky dchelimsky at gmail.com
Thu Jan 24 09:44:45 EST 2008


On Jan 24, 2008 3:47 AM, Kamal Fariz <kamal.fariz at gmail.com> wrote:
> > With 1.1.1 you can do this:
> >
> > Given "$n_users in the system" do |num_users|
> >  case num_users
> >  when "a user"
> >    # one user case
> >  when /(\d*) users/
> >    # multi user case using $1
> >  end
> > end
> >
> > With 1.1.2 you can do this:
> >
> > Given /(a|\d*) users? in the system/ do |num_users|
> >  num_users = (num_users == 'a') ? 1 : num_users.to_i
> >  (1..num_users).each do
> >   # ...
> >  end
> > end
>
> Didn't know you could do that! Thanks. So, the step will yield all the
> matches in the same order regexp will populate the matches array?

Yep.

Cheers,
David

>
>
> Regards,
> kamal
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list