[rspec-users] View-Driven-Development by Behavior-Driven-Development and RSpec

Mikel Lindsaar raasdnil at gmail.com
Mon Jul 30 06:49:28 EDT 2007

I find myself doing the same thing... the, open the model and type in
the it shoulds...

I ws thinking along the same line... probably all that would be needed
is a rake task that hooks into the Mock class and runs all the specs
taking not of all the stubs and mocks method calls that are made.

Then it could PRODUCE the it shoulds...

@model = mock_model(People, :id => 1, :name => "Bob")

# rake spec:find_fakes


describe People "automatically" do

  it "should have a name"

  it "should respond to alive?"


Now... that would be cool....



On 7/30/07, Daniel N <has.sox at gmail.com> wrote:
> On 7/30/07, Mikel Lindsaar <raasdnil at gmail.com> wrote:
> > Dear Nathan,
> >
> > What you are sayiing is correct, and in terms of Ruby on Rails, BDD
> > _IS_ View Driven development... or at least it should be IMHO.
> >
> > At the end of the day, the only thing that matters in a Rails App is
> > the Behaviour shown to the user, who has as their only interface, the
> > View.
> >
> > The user can not and should not interact with any models.  The user
> > MIGHT interact with a controller... (say, having a file download which
> > doesn't get sent through a view), but really... views ARE the
> > behaviour of a Rails App.
> >
> > I found the same thing as you... started with spec'ing my models,
> > doing great, getting to controllers.. doing OK... getting to views and
> > going "Where did I go wrong?"
> >
> > Starting with views and working "backwards" from a Test::Unit point of
> > view has definately opened up a lot of RSpec doors for me.
> >
> > My $0.02.
> >
> > Mikel
> I think one thing that would make view first development a really powerful
> tool with rspec is a way to keep track of erroneous calls to model methods.
> One thing that I am consistently worried about is specing a method in one
> place via mocks, a la the view, but forgetting to include that method in the
> model.
> The way I get around this at the moment, is when I find a method that I want
> to have that isn't there yet, I open up the spec for the model and add an
> it "should have method bla"
> so that it shows up in the pending report.  Of course this means that I have
> to have the model spec all setup in the first place kind of defeating the
> purpose of view first.  Well almost.  If the view is generated via an rspec
> generator then all that is setup.
> What would be fantastic is if mock had an option to report calls to
> non-existent methods.
> Something like mock( User, :report_pending_methods => :true )
> Is there another way to do this that is already in practice?
> Cheers
> Daniel
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list