On 20-jan-2009, at 15:29, David Chelimsky wrote:
On Tue, Jan 20, 2009 at 7:44 AM, Bart Zonneveld
<zuperinfin...@gmail.com> wrote:
Hey list,
As a good BDDer I want to test my views in isolation.
Sort of. A *good* BDDer wants to *specify* views in isolation. Testing
is for testers :)
You're right! I tend to talk a lot to non-programmers, and they get
that glaze-in-the-distance look in their eyes, whenever I mention
specifiy, spec'ing, or what have you :).
And as a good rails
programmer, I separate views into partials when needed. So, when
testing my
views, I want to stub out rendering of partials in my views. I'm
working on
upgrading an app from rails 2.1.2 to 2.2.2, using the latest rspec
and
rspec-rails.
I used to throw template.stub!(:render) in a before(:each) block
and be done
with it
That sounds kinda risky because you could be ignoring partials that
get rendered that you don't want to be rendered.
It is, most definately.
, but that doesn't work anymore. I can understand why, but now I have
to do something like template.stub!(:render).with(hash_including
(:partial =>
anything)). Except for when I'm testing a partial, then I need to
replace
the anything with every partial I'm rendering in my partial.
Is this the correct way,
Seems like the only way at the moment. Wouldn't call it correct or
incorrect.
I would call it ugly :). Not only do I have to remember the
hash_including part, but also the anything (and not :anything).
Conceptually, I like the template.stub!(:render). I render a
template, on which I stub all the renders. Whether that's risky or
not is a different discussion.
or is there perhaps something like
template.stub_partials :only => [], :except => [] ?
Nothing like this exists. Seems like a reasonable idea. Feel free to
submit a feature request, or better yet, a patch to
http://rspec.lighthouseapp.com
Will do!
cheers,
bartz
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users