[rspec-devel] rspec_on_rails, speccing models, adding it helpers...
dchelimsky at gmail.com
Tue Apr 1 18:09:48 EDT 2008
On Tue, Apr 1, 2008 at 5:29 PM, Zach Dennis <zach.dennis at gmail.com> wrote:
> I've got model helpers which perform reflection on associations to
> ensure a relationship exists as expected. It doesn't test the
> association (I think Rails does a pretty good job of ensuring the
> association works). I'm looking for feedback on if folks (and the
> rspec team =) would accept such a patch.
I'd rather see you publish this on its own. When we include things
like this in rspec proper, they become harder for us to change later.
> describe SomeModel do
> it_has_many :widgets, :destroy => :null, :class_name => "BaseWidget"
> it_has_one :fuzzbucket
> it_belongs_to :another_model
I see more and more structures appearing like this. I have very mixed
feelings about them. This is about structure, not behaviour. Even if
the underlying code is actually approaching this in a more behavioural
way, it's still expressing structure at the high level.
Also, if the widget's fuzzbucket moves to inside a
fuzzbucketcontainer, this all has to change. Whereas if the presence
of 0, 1 or many fuzzbuckets has some impact on behaviour, then
examples that express that impact will not have to change as the
internal widget structure changes.
> it relies on the top level describe's description_type to determine
> what model to reflect on. It removes a lot of boilerplate code for
> spec'ing standard associations.
> Zach Dennis
> rspec-devel mailing list
> rspec-devel at rubyforge.org
More information about the rspec-devel