The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
functional_test_matrix gets a nice little boost

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ryan Davis

Posts: 651
Nickname: zenspider
Registered: Oct, 2004

Ryan Davis is a ruby nerd.
functional_test_matrix gets a nice little boost Posted: May 16, 2007 6:55 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Ryan Davis.
Original Post: functional_test_matrix gets a nice little boost
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ryan Davis
Latest Posts From Polishing Ruby

Advertisement

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).

Before:

  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

After:

  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.

Before:

def matrix_test_unpub(...)
  # ...
end

After:

def matrix_test_unpublish(...)
  # ...
end

Read: functional_test_matrix gets a nice little boost

Topic: Ship It! Live: DC Edition - Featuring Andy Hunt... Registration is Open! Previous Topic   Next Topic Topic: TMBG: The Else

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use