[rspec-users] [ANN] rspec_todo -- spec'ing backwards

Pat Maddox pergesu at gmail.com
Sun Sep 16 15:04:16 EDT 2007


On 9/16/07, s.ross <cwdinfo at gmail.com> wrote:
> While the spirit of BDD is to spec first and code second, many of us
> have legacy code. Worse, some of us have legacy code without very
> good coverage. Recognizing that *I* have such code, I created a
> script that grinds through your .rb files and creates placeholder
> specs for each public method.
>
> While it is more sensible to spec behavior of code function than of
> individual methods, this tool can help jump start a transition to
> that wonderful place. Comments welcome (and please be kind about the
> code -- I know it needs refactoring :).
>
> svn:
>
> http://svn.calicowebdev.com/rspec_todo/trunk
>
> Excerpt from the readme:
>
> Usage is:
>
>    ruby spec_todo.rb <options> <files>
>
> Options are:
>
>    -m -- Wrap each file's spec in a module
>
>    -u -- Use "it" with a block and a pending method rather than a "it"
>
>
> So, for example, I might use it as follows:
>
>    ruby spec_todo.rb app/models/* app/controllers/*
>
> Here is a brief example of the output of this tool:
>
>
>        #------------------------------------------------------------
>        # File: app/controllers/contact_controller_spec.rb
>        #------------------------------------------------------------
>
>        require File.dirname(__FILE__) + '/../spec_helper'
>
>        describe "A ContactController" do
>          it "should do something sensible with index."
>          it "should do something sensible with thank_you."
>        end
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>

Jim Weirich has a great article where he uses a technique to retrofit
legacy code with specs.
http://onestepback.org/index.cgi/Tech/Ruby/FlexMockAndFluidDynamics.red

Pat


More information about the rspec-users mailing list