The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Ruby: Creating Custom Assertions

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
Jay Fields

Posts: 765
Nickname: jayfields
Registered: Sep, 2006

Jay Fields is a software developer for ThoughtWorks
Ruby: Creating Custom Assertions Posted: Sep 4, 2007 6:50 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jay Fields.
Original Post: Ruby: Creating Custom Assertions
Feed Title: Jay Fields Thoughts
Feed URL: http://blog.jayfields.com/rss.xml
Feed Description: Thoughts on Software Development
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jay Fields
Latest Posts From Jay Fields Thoughts

Advertisement
I've previously written about creating custom assertions for delegation and Validatable validations. Both solutions followed the same pattern, which is very similar to the example below.

Model.verify do
fluent.interface
fluent.interface
...
end

I do like the readability provided by the pattern; however, it isn't a practical solution.

My colleague and friend, John Hume, also created a solution for testing delegation: Handoff. The thing I really like about Handoff is that it follows the traditional test definition pattern.

def test_description
assert_handoff....
end

At first glance this might not seem like a big deal; however, following the traditional pattern is crucial when you want to run a test in isolation.

A large problem with my delegation custom assertion is that you must run all the tests in a file if you want the delegation tests to run. It's possible to create ways to run the individual lines; however, with each custom assertion a new way to run it in isolation must be devised. A far simpler solution is to stick to the common test definition pattern and leverage existing tools that know how to run one test at a time.

The next release of Validatable will include custom assertions that follow the traditional test definition pattern.

Read: Ruby: Creating Custom Assertions

Topic: In Place Editor and Collection Partials Previous Topic   Next Topic Topic: Guess who's back? Finally!

Sponsored Links



Google
  Web Artima.com   

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