module Roda::RodaPlugins::RenderCoverage

The render_coverage plugin builds on top of the render plugin and sets compiled_path on created templates. This allows Ruby’s coverage library before Ruby 3.2 to consider code created by templates. You may not need this plugin on Ruby 3.2+, since on Ruby 3.2+, coverage can consider code loaded with eval. This plugin is only supported when using tilt 2.1+, since it requires the compiled_path supported added in tilt 2.1.

By default, the render_coverage plugin will use coverage/views as the directory containing the compiled template files. You can change this by passing the :dir option when loading the plugin. By default, the plugin will set the compiled_path by taking the template file path, stripping off any of the allowed_paths used by the render plugin, and converting slashes to dashes. You can override the allowed_paths to strip by passing the :strip_paths option when loading the plugin. Paths outside :strip_paths (or the render plugin allowed_paths if :strip_paths is not set) will not have a compiled_path set.

Due to how Ruby’s coverage library works in regards to loading a compiled template file with identical code more than once, it may be beneficial to run coverage testing with the RODA_RENDER_COMPILED_METHOD_SUPPORT environment variable set to no if using this plugin.