On 9/16/07, <b class="gmail_sendername">Mark Van De Vyver</b> &lt;<a href="mailto:mvyver@gmail.com">mvyver@gmail.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>On 9/17/07, David Chelimsky &lt;<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>&gt; wrote:<br>&gt; On 9/16/07, s.ross &lt;<a href="mailto:cwdinfo@gmail.com">cwdinfo@gmail.com</a>&gt; wrote:<br>&gt; &gt; While the spirit of BDD is to spec first and code second, many of us
<br>&gt; &gt; have legacy code. Worse, some of us have legacy code without very<br>&gt; &gt; good coverage. Recognizing that *I* have such code, I created a<br>&gt; &gt; script that grinds through your .rb files and creates placeholder
<br>&gt; &gt; specs for each public method.<br>&gt; &gt;<br>&gt; &gt; While it is more sensible to spec behavior of code function than of<br>&gt; &gt; individual methods, this tool can help jump start a transition to<br>&gt; &gt; that wonderful place.
<br>&gt;<br>&gt; Hi Steve,<br>&gt;<br>&gt; There are tools that will do this for you on java projects and in<br>&gt; nearly every case that I&#39;ve seen them used, the result has been 100<br>&gt; line test methods, one per object method, that take the object through
<br>&gt; multiple states, become impossible to understand, and often just get<br>&gt; commented out.<br>&gt;<br>&gt; Worse, even though you sell it as a tool for dealing with legacy code<br>&gt; (code without tests), it will end up becoming the tool people use and,
<br>&gt; even worse than that, they&#39;ll think it&#39;s BDD because it creates specs<br>&gt; and not tests.<br>&gt;<br>&gt; I beg you (I&#39;m on my knees as I&#39;m writing this) to throw this<br>&gt; manuscript in the fire now!
<br><br>Hmm, I&#39;ve never heard of this approach (burning stuff) ending in joy...<br>Perhaps what you&#39;d like is a one line comment to be prepended to each<br>spec file pointing to spec best/good practice?<br>I&#39;d nominate someone&#39;s(;) ) &#39;One expectation per example&#39; page:
<br><a href="http://rubyurl.com/2jw">http://rubyurl.com/2jw</a><br>For example:<br># Visit the following page for an excellent illustration of how to specify code:<br># <a href="http://rubyurl.com/2jw">http://rubyurl.com/2jw
</a><br><br>Or, you might prefer that any newbie sees that for each method there<br>are multiple &#39;it&#39;s&#39; prepared? Or maybe the template pending text<br>should read:<br>&quot;should specify one expectation per example&quot;
<br><br>Given these are just clutter things for some expert who is extending<br>existing code using a BDD approach, and they just want a skeleton of<br>&#39;what&#39;s in there&#39;, you might ask for an &#39;-e&#39;xpert switch that turns
<br>these defaults off.<br><br>Would that advance anything?<br><br>My 2c.</blockquote><div><br>Hey,<br><br>Just joined the list less than an hour ago, but I&#39;ve been using RSpec consistently since May. This looks like an interesting topic, and thought I&#39;d chime in. I&#39;m currently working with a crapload of legacy code. But it&#39;s not in Ruby. It&#39;s in Visual Basic. Not quite the same issue, but similar in some ways. For the most part, I&#39;m completely ignoring all the old code. The business logic, the part of the code that actually matters, is what I try to fish out, and run tests against. If that legacy code is just presentation/controller/database logic, don&#39;t loose sleep over it. But don&#39;t take my word for it. Here&#39;s a few other opinions:
<br><br><a href="http://www.slideshare.net/rabble/testing-legacy-rails-apps/">http://www.slideshare.net/rabble/testing-legacy-rails-apps/</a><br><br>Not sure who this guy is, but I guess this was presented at RailsConf &#39;07. He suggests just testing when bugs are found, or when refactoring needs to be done. Otherwise, you might waste your time.
<br><br><a href="http://gilesbowkett.blogspot.com/2007/08/getting-legacy-code-under-test.html">http://gilesbowkett.blogspot.com/2007/08/getting-legacy-code-under-test.html</a><br><br>My boy Giles Bowkett has a completed opposite take: Do a manual &quot;heckle&quot; on all that legacy code, and find out what&#39;s necessary and what&#39;s not. I probably wouldn&#39;t bother doing this by hand, but if you want something more solid that just fishing out bugs, I&#39;d suppose this would work.
<br><br>-Rob<br>&nbsp;</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">&gt; FWIW,<br>&gt; David<br>&gt;<br>&gt; &gt; Comments welcome (and please be kind about the
<br>&gt; &gt; code -- I know it needs refactoring :).<br>&gt; &gt;<br>&gt; &gt; svn:<br>&gt; &gt;<br>&gt; &gt; <a href="http://svn.calicowebdev.com/rspec_todo/trunk">http://svn.calicowebdev.com/rspec_todo/trunk</a><br>&gt; &gt;
<br>&gt; &gt; Excerpt from the readme:<br>&gt; &gt;<br>&gt; &gt; Usage is:<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;ruby spec_todo.rb &lt;options&gt; &lt;files&gt;<br>&gt; &gt;<br>&gt; &gt; Options are:<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;-m -- Wrap each file&#39;s spec in a module
<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;-u -- Use &quot;it&quot; with a block and a pending method rather than a &quot;it&quot;<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; So, for example, I might use it as follows:<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;ruby spec_todo.rb app/models/* app/controllers/*
<br>&gt; &gt;<br>&gt; &gt; Here is a brief example of the output of this tool:<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#------------------------------------------------------------<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;# File: app/controllers/contact_controller_spec.rb
<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#------------------------------------------------------------<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;require File.dirname(__FILE__) + &#39;/../spec_helper&#39;<br>&gt; &gt;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;describe &quot;A ContactController&quot; do
<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it &quot;should do something sensible with index.&quot;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it &quot;should do something sensible with thank_you.&quot;<br>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&gt; &gt;<br>&gt; &gt; _______________________________________________
<br>&gt; &gt; rspec-users mailing list<br>&gt; &gt; <a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br>&gt; &gt; <a href="http://rubyforge.org/mailman/listinfo/rspec-users">http://rubyforge.org/mailman/listinfo/rspec-users
</a><br>&gt; &gt;<br>&gt; _______________________________________________<br>&gt; rspec-users mailing list<br>&gt; <a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br>&gt; <a href="http://rubyforge.org/mailman/listinfo/rspec-users">
http://rubyforge.org/mailman/listinfo/rspec-users</a><br>&gt;<br>_______________________________________________<br>rspec-users mailing list<br><a href="mailto:rspec-users@rubyforge.org">rspec-users@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/rspec-users">
http://rubyforge.org/mailman/listinfo/rspec-users</a><br></blockquote></div><br>