[rspec-devel] RSpec Rails generators proposal

Pedro Mariano Belo pedrobelo at gmail.com
Sat Dec 8 03:41:39 EST 2007

Hello guys,

First of all thanks for this beautiful framework :)

I'm just someone trying BDD and I have some ideas regarding RSpec
Rails generators: It's great to have RSpec generators tied with Rails
models, controllers and scaffolds -- but I think there's one kind of
spec missing in there, one that should exist before all others: the
single, decoupled spec.

To quote Wikipedia, BDD "is a software development technique that
questions the behavior of an application before and during the
development process". And the problem is, right now we have no
generator that allows us to write specs before the development
process. We have to do a little of software design to figure out what
models/controllers our application will require so we can start
writing specs.

So my proposal is:
* Rename the current rspec generator to rspec_base or rspec_setup or
something like this (btw, isn't it weird that the generator with the
most generic and minimal name is the one used only once?)
* Create a new rspec generator that receives one spec name as
parameter and generates a minimal spec in spec/general

Actually I did this already and I'm using it. So I normally begin
projects running the generator with "script/generate rspec
application_name". It generates the file
spec/general/application_spec.rb, with:

require File.dirname(__FILE__) + '/../spec_helper'

describe 'Application name' do
  it 'should ...'

So I can quickly add examples and define a spec without thinking about
models or controllers. Later, when generating a model, I normally move
related examples from this general spec to the model spec and start
adding blocks to define them.

What do you guys think?

I was going to send a patch but I couldn't do it because svn won't
allow me to do all changes at once. So attached is my generators
folder, compressed. And I never wrote a generator before so I'm sure
this one sucks. But, anyways, it's working for me :)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: generators.zip
Type: application/zip
Size: 19959 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rspec-devel/attachments/20071208/b1005578/attachment-0001.zip 

More information about the rspec-devel mailing list