[rspec-users] Cucumber - stub! or mock?

David Chelimsky dchelimsky at gmail.com
Mon Sep 15 17:15:09 EDT 2008

On Mon, Sep 15, 2008 at 4:01 PM, Joseph Wilk <lists at ruby-forum.com> wrote:
> Tim Glen wrote:
>> 1. Is there a way to stub out the model to return some fixture-type
>> records?
>> 2. Does anyone have an idea as to how we could refactor this into a
>> better pattern? Those 2 "projects" are pretty specific to the
>> production data and will "never be edited," but it still doesn't make
>> me comfortable.
>> I'm not sure how to phrase this better. Let me know what other detail
>> I can provide to make it more clear what I'm looking for.
>> thanks,
>> tim
> As Pat said I would avoid mocking/stubbing, you want your cucumber tests
> to cut through all the layers of your app including touching the
> database.
> As for setting up the data, I tend not to use fixtures (I only want to
> have the data created for certain tests). Instead I save the relevant
> models in the Given steps, preparing for the feature test. If you are
> going to repeat the given steps a lot I would extract the model set-up
> into a ruby function and reuse this.

You might also take a look at http://github.com/flogic/object_daddy.


> --
> Joseph Wilk
> http://www.joesniff.co.uk
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list