[rspec-users] Render template not matching absolute path

Ashley Moran work at ashleymoran.me.uk
Tue Aug 21 05:07:28 EDT 2007


Hi

I have a simple controller method like this:

class StylesheetsController < ApplicationController
   layout  nil
   session :off

   def gap
     site = Site.find_by_hostname(request.host)
     @colours = site.colours
     respond_to do |accepts|
       accepts.css { render :file => "#{RAILS_ROOT}/app/views/ 
stylesheets/gap.rcss" }
     end
   end
end

And I want to test that it renders the gap.rcss file, but my spec,

     it "should render the gap.rcss template" do
       do_get
       response.should render_template("gap.rcss")
     end

fails with this error:

Expected "gap.rcss", got "/Users/ashleymoran/Documents/Development/ 
YourMoney/trunk/src/config/../app/views/stylesheets/gap.rcss"

I don't remember this failing in 1.0.5, but it's been a while since I  
worked on this project so might be just be my bad memory.  Am I doing  
something wrong or can you not spec "render :file" with render_template?

Thanks
Ashley





More information about the rspec-users mailing list