From: Jason Roelofs Date: 2006-10-03T22:59:43+09:00 Subject: Re: [ANN] test/spec 0.1, a BDD interface for Test::Unit ------=_Part_10561_18430594.1159883979813 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/3/06, Rob Sanheim wrote: > > On 9/29/06, Christian Neukirchen wrote: > > Hello, > [snip] > > You can use assert_* freely in specify-blocks; Object#should works in > > Test::Unit test cases, too, but doesn't increase the assertion count. > [/snip] > > Happy hacking and have a nice day, > > Christian Neukirchen > > > > 9861cf92ec39cce7a5e96504f1fdb6f0 testspec-0.1.0.tar.gz > > -- > > Christian Neukirchen http://chneukirchen.org > > > Looks very interesting. > > Is there a reason that calls to "should" don't increase the assertion > count? Seeing as they are sort of equivalent, and seeing the > assertion count is a helpful thing, it would be nice. Or maybe there > should be a general "verification count" that includes calls to > should? > > Here is one hack to do the assertion counts, btw: > http://www.io.com/~wazmo/blog/archives/2006_05.html#000238 > > - rob > > -- > http://www.robsanheim.com > http://www.seekingalpha.com > http://www.ajaxian.com > > Interesting. We use an ad-hoc #should for BDD where I work: (in our Rails test_helper.rb ): class Test::Unit::TestCase def self.should(behave,&block) mname = "test_should_#{behave}" if block define_method mname, &block else define_method mname do flunk "#{self.class.name.sub(/Test$/,'')} should #{behave}" end end end end This allows us to write tests as such: should "open the index page" do get '/' assert_response :success end As the method name is prefixed by 'test_' it does get counted in the assertion count. If you'll notice, too, the method name actually gets defined as: 'test_should_open the index page' which because of the way the method is created and called, is never a problem with the parser and makes for easier to read error messages. Maybe you can use this to help with counting your 'shoulds' in this library. Jason ------=_Part_10561_18430594.1159883979813--