[rspec-devel] huge setup methods? I think I'm on the wrong path
jcfischer.lists at gmail.com
Thu Jan 25 01:05:23 EST 2007
> 1. Keep the Demeterites happy
> 2. Make code easier to read
> 3. Make code easier to spec
> A simple example:
> class Client < ActiveRecord::Base
> has_many :people
> class Person < ActiveRecord::Base
> belongs_to :person
> def client_name
> You can just do:
> person = mock('person')
Ahh - I have been using this a lot in an other application. Thanks
for providing some background information on *why* I have been doing
> This does mean a small amount of extra code in your app, but really
> not too much, and probably less than you'd be adding to your specs to
> stub around it.
True. Compared to the stubbing, it's nothing!
> We wrote a plugin that will create some of these for you
> automatically that wrap Rails' association proxies. It's part of a
> set of other convenient tools and Rails 'hacks' (hello Pot, this is
I will check that out - sounds useful!
> Goldilocks sense of the word, but it works for now and saves lots o'
> context "A person completing a task"
> setup do
> mock_model(:client, :name => 'Heys')
> mock_model(:person, :client => @campaign, :first_name =>
> "Joe", :tasks => )
> # ...
That looks extremely helpful as well. Thanks for pointing these
While BDD seems so simple in the beginning, it's the nitty gritty
that makes for some headscratching.
More information about the rspec-devel