1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/test/template/erb/erbubi_test.rb
Jonathan Hefner cd2b3be9a6 Allow Erubi bufvar to be configured
This allows `render_in` components that compile their own templates to
use their view context's current output buffer while a
`with_output_buffer` block is being evaluated.

Partially addresses #39377.
2020-05-21 15:22:51 -05:00

21 lines
527 B
Ruby

# frozen_string_literal: true
require "abstract_unit"
require "action_view/template/handlers/erb/erubi"
class ErubiTest < ActiveSupport::TestCase
test "can configure bufvar" do
template = <<~ERB
foo
<%= "foo".upcase %>
<%== "foo".length %>
ERB
baseline = ActionView::Template::Handlers::ERB::Erubi.new(template)
erubi = ActionView::Template::Handlers::ERB::Erubi.new(template, bufvar: "boofer")
assert_equal baseline.src.gsub("#{baseline.bufvar}.", "boofer."), erubi.src
end
end