[rspec-users] Testing lib code

s.ross cwdinfo at gmail.com
Tue Dec 30 12:50:55 EST 2008


Hello--

This question has, I'm sure, been asked and answered hundreds of  
times, but I was unable to turn up anything in Google. Here's the  
issue: I have some code in a Rails app in the lib/ directory that  
affects how views are rendered. Specifically, it checks CSS and  
Javascript files for existence and some application-specific stuff,  
then injects them into the right part of the HTML that's rendered.

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.

Thanks,

Steve


More information about the rspec-users mailing list