Add `with_preview_paths` test helper

This commit is contained in:
Nishiki Liu 2021-02-16 17:36:40 -08:00
Родитель 435151e05f
Коммит e451184210
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -21,6 +21,18 @@ ENV["RAILS_ENV"] = "test"
require File.expand_path("../config/environment.rb", __FILE__)
require "rails/test_help"
# Sets custom preview paths in tests.
#
# @param new_value [Array<String>] List of preview paths
# @yield Test code to run
# @return [void]
def with_preview_paths(new_value)
old_value = Rails.application.config.view_component.preview_paths
Rails.application.config.view_component.preview_paths = new_value
yield
Rails.application.config.view_component.preview_paths = old_value
end
def with_preview_route(new_value)
old_value = Rails.application.config.view_component.preview_route
Rails.application.config.view_component.preview_route = new_value