아, 그래서 알아 냈습니다! 이러한 의견에 명시된 것 : - 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에 레일 빈 소스를 가지고 템플릿을 스터브 (오히려 전체 렌더링 과정이 너무 제대로 레일 등 형식/MIME 종류/처리 스텁보다.), rabl 핸들러는 블랭크 소스를보고 파일 시스템 읽기를 결정합니다. 따라서 rabl 또는 rspec-rails 중 하나를 사용하면이 작업을 수행 할 때 약간의 조정이 필요합니다. 지금은 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
또한 erb/haml 템플릿에도 이러한 현상이 발생하지 않습니다. –
rspec-rails 프로젝트에서 문제점을 열어 보셨습니까? 그렇지 않다면, 왜? – shingara
예, 내 대답은 아래 링크를 게시했습니다 : https://github.com/rspec/rspec-rails/issues/565#issuecomment-6479742 David Chelimsky와의 대화에서 알 수 있듯이 템플릿 엔진 Rabl처럼) 빈'template.source'를 다룰 수 있어야합니다. David Sommers는 Rabl이'self.call (template)'의'if template.source.empty?'부분을 제거 할 것이라고 말했다 (아래 참조). 사실, 이미 커밋되었습니다 : https://github.com/nesquena/rabl/commit/e7be8bea95ea12603d7b9581330020b2589a683d. –