[rspec-users] Testing lib code
sfeley at gmail.com
Tue Dec 30 13:59:17 EST 2008
On Tue, Dec 30, 2008 at 12:50 PM, s.ross <cwdinfo at gmail.com> wrote:
> The question is: How to spec? I have spec'ed that the stuff that *will* be
> injected is correctly formed. However, to fully test the code, I need to
> test that the stuff that *is* injected is there. Kind of:
> response.should have_tag('script', /application.css/)
> But there is no response object and that's what I'm wrestling with.
> I'll betcha there's an easy solution, but I'm not seeing it.
I'd either write a simple 'dummy' request (to one of your existing
controllers or make one on the fly) to catch that output, or I'd spec
it as a shared behavior and include it in my other request tests
wherever the behavior is needed. The first has better encapsulation
if you want to split that library out later as a gem or something; the
second is a little more transparent and application-focused.
Steve Eley (sfeley at gmail.com)
ESCAPE POD - The Science Fiction Podcast Magazine
More information about the rspec-users