Sha256: ceb3bb93fb5c8ec6447147f6010c4dac49d7b7dbd524db869553183aecd0f18e

Contents?: true

Size: 654 Bytes

Versions: 1

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require "action_view/testing/resolvers"

module TestActionView
  def self.render(source, **ivars)
    JSON.parse(new(source, **ivars).render(template: "source"))
  end

  def self.new(source, **ivars)
    resolver = ActionView::FixtureResolver.new({ "source.json.nm" => source })
    lookup_context = ActionView::LookupContext.new([resolver], {}, [""])
    controller = ActionView::TestCase::TestController.new

    view =
      ActionView::Base.with_empty_template_cache.new(
        lookup_context,
        ivars.to_h,
        controller,
      )
    def view.view_cache_dependencies
      []
    end

    view
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-nm-0.1.0 test/support/test_action_view.rb