🕷 zenspider.com

by ryan davis

Looking for the Ruby Quickref?

functional_test_matrix gets a nice little boost

Published 2007-05-16 @ 17:03

Tagged zentest, rails, ruby, minitest

I’ve been wanting to do something like this for a little while… Namely, I was getting tired of cryptic little codes for everything. Here and there I don’t mind, but for every action I’d rather the nominal case fade into the background. So, like :na, I added :OK, which has the added benefit of rendering green instead of blue in emacs (because it is uppercase, I think ruby-mode thinks it is a const).


  matrix :pages,     :c_rw, :c_W,  :c_R,  :o_rw, :g_c,  :a_rw, :a_W, :a_R
  action :delete,    :del,  :del,  :del,  :del,  :e_NF, :del,  :del,  :del
  action :edit,      :edit, :edit, :edit, :edit, :e_NF, :edit, :edit, :edit
  action :publish,   :pub,  :pub,  :pub,  :pub,  :e_NF, :pub,  :pub,  :pub
  action :unpublish, :unpb, :unpb, :unpb, :unpb, :e_NF, :unpb, :unpb, :unpb
  action :update,    :updt, :updt, :updt, :updt, :e_NF, :updt, :updt, :updt
  action :view,      :view, :view, :view, :view, :e_NF, :view, :view, :view


  matrix :pages,     :c_rw, :c_W, :c_R, :o_rw, :g_c,  :a_rw, :a_W,  :a_R
  action :delete,    :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :edit,      :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :publish,   :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :unpublish, :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :update,    :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK
  action :view,      :OK,   :OK,  :OK,  :OK,   :OK,   :OK,   :e_NF, :OK

See how nice all those error cases pop out at you now? I love that. Now I can gloss over the green OKs and question everything else (n/a’s and errors alike). It’ll help me question my requirements even more.

:OK dispatches to a validator with the same name as the action, so now they’re more readable.


def matrix_test_unpub(...)
  # ...


def matrix_test_unpublish(...)
  # ...