You can try to stub this refresh call in the beinning of your spec
ActionView::Template.any_instance.stub(:refresh)
Question
We use render inline
in our rails 3.2
app:
<%= render inline: @erb_code, locals: {f: f} %>
Here @erb_code
returns a string of ERB code
for rendering. The problem with this inline is that the @virtual_path
is set to false in rendering which causes error in spec in refresh(view)
of ActionView::Template
. Here is the error:
ActionView::Template::Error:
A template needs to have a virtual path in order to be refreshed
Here is the line in definition of refresh which causes error:
raise "A template needs to have a virtual path in order to be refreshed" unless @virtual_path
The full definition of the refresh(view)
is available at http://api.rubyonrails.org/classes/ActionView/Template.html.
How to set @virtual_path
true in rspec to avoid the spec error? But the execution of the code seems having no error. Tried assign true to @virtual_path
in spec and it did not work.
Solution
You can try to stub this refresh call in the beinning of your spec
ActionView::Template.any_instance.stub(:refresh)