[rspec-users] active_scaffold partials

Jonathan Linowes jonathan at parkerhill.com
Wed Aug 15 03:40:38 EDT 2007


An issue I've run into is with a controller using the active_scaffold  
plugin, which injects a method that modifies the search path for  
partial files. When I try to run a spec on a a_s partial it reports  
the file cannot be found.

I think this is the a_s code that does it but I'm not sure where to  
go from there to get rspec to handle it. Any suggestions would be  
appreciated.

file: plugins/active_scaffold/lib/extensions/action_view.rb

module ActionView #:nodoc:
   class Base
	...

     def render_partial_with_active_scaffold(partial_path,  
local_assigns = nil, deprecated_local_assigns = nil) #:nodoc:
       if self.controller.class.respond_to?(:uses_active_scaffold?)  
and self.controller.class.uses_active_scaffold?
         partial_path = rewrite_partial_path_for_active_scaffold 
(partial_path)
       end
       render_partial_without_active_scaffold(partial_path,  
local_assigns, deprecated_local_assigns)
     end
      
alias_method :render_partial_without_active_scaffold, :render_partial
     alias_method :render_partial, :render_partial_with_active_scaffold

     private

     def rewrite_partial_path_for_active_scaffold(partial_path)
       path, partial_name = partial_pieces(partial_path)

       # test for the actual file
       return partial_path if file_exists? File.join(path, "_# 
{partial_name}")

       # check the ActiveScaffold-specific directories
       ActiveScaffold::Config::Core.template_search_path.each do | 
template_path|
         return File.join(template_path, partial_name) if  
file_exists? File.join(template_path, "_#{partial_name}")
       end
       return partial_path
     end
   end
end





More information about the rspec-users mailing list