Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Snippet - assert_yin_yang
Phlip
11/10/2007 3:51:00 AM
Rubies:
This is a Rails assertion, but any project could use its concept.
It asserts that a Model value is one state before a block, and another
state after:
def assert_yin_yang(object, method, yin, yang, diagnostic = nil)
message = build_message(diagnostic, "<?>#<?>", object, method)
assert_equal yin, object.send(method), message
yield
object.reload
assert_equal yang, object.send(method), message
end
Detect something switched from false to true like this:
helmet = shrew.accessories.first
assert_yin_yang helmet, :active, false, true do
post :use, :id => helmet.id
end
Any tips welcome regarding making this more yin-yang-ey!
--
Phlip
http://c2.com/cgi/...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Snippet - assert_yin_yang
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password