This is interesting. I really like the python doctest stuff, but, while using it with a friend on writing something, it seemed almost to start to get cumbersome for lots of examples. I have several specs per method, so I wonder how it scales.<br>
<br>-Corey<br><br><div class="gmail_quote">On Tue, Feb 26, 2008 at 3:54 PM, Matthijs Langenberg <<a href="mailto:mlangenberg@gmail.com">mlangenberg@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
It would almost be possible to generate the actual ruby code from the quicktest method ;-). <br><br>To be honest, I like it that my examples don't mix with the actual code, it looks a bit cleaner. Interesting approach though, maybe I'll give it a shot.<br>
<br><br><div class="gmail_quote"><div><div></div><div class="Wj3C7c">On Tue, Feb 26, 2008 at 1:56 PM, greg weber <<a href="mailto:webs.dev@gmail.com" target="_blank">webs.dev@gmail.com</a>> wrote:<br></div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">
== ABOUT<br>Quicktest is a utility for inlining ruby unit tests with the ruby code under test<br><br>The typical test driven development workflow requires constant switching between the file containg the source code and the the file containg the tests. When creating code, it can be more convenient to place tests immediately after the code you are writing. After the code has been written, it may be a good idea to move it to another file, but the option to permanently keep tests with the source is available (useful for scripts).<br>
<br>Quicktest is designed to support quick tests in a framework agnostic way. Currently, only an rspec testrunner is available, but it is trivial to write one for another testing framework.<br><br>== FEATURES<br>Quicktest uses method tracing to know the method you are testing. By default the output of a failed test will show the object and method name.<br>
<br>== USAGE<br>To test a method, place another method called 'quicktest' immediately after it<br>the quicktest method has three OPTIONAL arguments<br>- the test runner object<br>- a reference to self<br>- a method object for the method under test<br>
<br>run with spec -r quicktest file_to_test<br><br>There is a convenience script so that you can just run<br><br> quickspec file_to_test<br><br>== NOTES<br>- leaving test code in with your production code is not necessarily a good idea, but there is almost no runtime overhead to doing so since ruby will not evaluate code in a method until the method is invoked<br>
- quicktest instance methods not working properly? if the class (or one of its ancestors) is overriding method tracing than including QuickTest::Tracer will fix it.<br><br><br>example: run with bin/quickspec<br><br>class Foo<br>
attr_reader :bar<br><br> def initialize<br> @bar = true<br> end<br> def quicktest t, s<br> <a href="http://t.it" target="_blank">t.it</a> "bar should be initialized to true" do<br> s.bar.should == true<br>
end<br>
end<br><br> def self.hello arg<br> "hello" + arg<br> end<br> def self.quicktest t, s, meth<br> <a href="http://t.it" target="_blank">t.it</a> "should prepend 'hello' to its argument" do<br>
meth["world"].should == 'hello world' # error - no space 'helloworld'<br>
end<br> end<br>end<br><br><br>Running quicktest on the above outputs the following:<br>.F<br><br>1)<br>'Foo hello should prepend 'hello' to its argument' FAILED<br>expected: "hello world",<br>
got: "helloworld" (using ==)<br>./README:22:in `quicktest'<br>/home/greg/quicktest/lib/quicktest.rb:65:in `instance_eval'<br>/home/greg/quicktest/lib/quicktest.rb:65:in `run_tests'<br><br>Finished in 0.008338 seconds<br>
<br>2 examples, 1 failure<br>
<br></div></div>_______________________________________________<br>
rspec-devel mailing list<br>
<a href="mailto:rspec-devel@rubyforge.org" target="_blank">rspec-devel@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/rspec-devel" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-devel</a><br></blockquote></div><br>
<br>_______________________________________________<br>
rspec-devel mailing list<br>
<a href="mailto:rspec-devel@rubyforge.org">rspec-devel@rubyforge.org</a><br>
<a href="http://rubyforge.org/mailman/listinfo/rspec-devel" target="_blank">http://rubyforge.org/mailman/listinfo/rspec-devel</a><br></blockquote></div><br><br clear="all"><br>-- <br><a href="http://www.coreyhaines.com">http://www.coreyhaines.com</a><br>
The Internet's Premiere source of information about Corey Haines