Ah, so I figured it out! It's outlined in these comments:
- https://github.com/nesquena/rabl/issues/37#issuecomment-6474467
- https://github.com/rspec/rspec-rails/issues/565#issuecomment-6474362
def self.call(template)
source = if template.source.empty?
File.read(template.identifier)
else # use source
template.source
end
%{ ::Rabl::Engine.new(#{source.inspect}).
render(self, assigns.merge(local_assigns)) }
end # call
rspec-rails stubs out templates to have a blank source (rather than stubbing the whole rendering process so rails properly handles formats/mime-types/etc.), and the rabl handler sees the blanks source and decides to read the file-system. So either rabl or rspec-rails will need a slight tweak to get this working. For now I've monkey patched rspec-rails:
class EmptyTemplatePathSetDecorator < ::ActionView::Resolver
attr_reader :original_path_set
def initialize(original_path_set)
@original_path_set = original_path_set
end
# @api private
def find_all(*args)
original_path_set.find_all(*args).collect do |template|
::ActionView::Template.new(
" ", # <======================== this is not "empty"
template.identifier,
template.handler,
{
:virtual_path => template.virtual_path,
:format => template.formats
}
)
end
end
end