[rspec-users] Correct way to spec partials
jesse at jesseclark.com
Tue Nov 11 19:51:59 EST 2008
On Oct 26, 4:49 am, "David Chelimsky" <dchelim... at gmail.com> wrote:
> On Thu, Oct 23, 2008 at 8:07 PM, Oleksandr Rudyk <alex.ru... at gmail.com> wrote:
> > Hi everybody,
> > 1) Does anybody have full working example of how to test partial templates?
> > 2) What the correct place to testpartials: controller or view spec? If
> > controller correct place,
> > should I use integrate_views?
> There are basically three options (from most granular to most coarse):
> 1. view examples rendering the partial directly
> 2. view examples rendering a template that includes the partial
> 3. controller examples with integrate_views
> In practice, I don't think I ever go for #3, and the choice between #1
> and #2 is largely context-dependent. In the end you want to (or
> rather, I want you to ;) ) be equally comfortable with all three
> approaches, understand the pros and cons of each, and make a decision
> on a case by case basis.
Where can I find more information about how various contexts affect
the choice between #1 and #2?
I have a partial that is shared by two view templates and I only want
to test the partial once. So I created a new spec file with a describe
block for the partial. The partial is passed some locals and I would
like to test in my examples that these local variables are displayed
as expected. How would I go about setting these in the example so they
are available to the partial when it renders?
More information about the rspec-users