require 'bundler/setup'
require 'minitest/autorun'
require 'mocha/setup'

require 'action_view'
require 'active_support/core_ext/kernel/reporting'
require 'active_model'

require 'record_tag_helper'

silence_warnings do
  Encoding.default_internal = "UTF-8"
  Encoding.default_external = "UTF-8"
end

module RenderERBUtils
  def view
    @view ||= begin
      path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH)
      view_paths = ActionView::PathSet.new([path])
      ActionView::Base.new(view_paths)
    end
  end

  def render_erb(string)
    @virtual_path = nil

    template = ActionView::Template.new(
      string.strip,
      "test template",
      ActionView::Template::Handlers::ERB,
      {}
    )

    template.render(self, {}).strip
  end
end

require 'bundler/setup'
require 'minitest/autorun'
require 'mocha/setup'

require 'action_view'
require 'active_support/core_ext/kernel/reporting'
require 'active_model'

require 'record_tag_helper'

silence_warnings do
  Encoding.default_internal = "UTF-8"
  Encoding.default_external = "UTF-8"
end

module RenderERBUtils
  def render_erb(string)
    @virtual_path = nil

    template = ActionView::Template.new(
      string.strip,
      "test template",
      ActionView::Template::Handlers::ERB,
      {format: :html, locals: []}
    )
    self.render(template: template)
  end
end

Fix tests for Rails 6
Fix tests for Rails 6

Template rendering has changed in [1] which causes tests to fail on
Rails 6. This changes the `render_erb` test helper to be compatible
with both Rails 5 and Rails 6.
Also removes unused `view` method.

[1] https://github.com/rails/rails/commit/db4b77aca147ec3c7376d803fc6ccb14c9195352#diff-e78f6b2a39ac178601ac63b89f981f98
