File: test_helper.rb

package info (click to toggle)
ruby-view-component 4.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,832 kB
  • sloc: ruby: 8,385; sh: 166; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 882 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

require "simplecov"
require "simplecov-console"

require "bundler/setup"
require "minitest/autorun"
require "rails"
require "rails/generators"
$LOAD_PATH.unshift "./test/test_engine/lib"
require "test_engine"
require "view_component"

Rails::Generators.namespace = TestEngine

def with_config_option(option_name, new_value, config_entrypoint: TestEngine::Engine.config.view_component)
  old_value = config_entrypoint.public_send(option_name)
  config_entrypoint.public_send(:"#{option_name}=", new_value)
  yield
ensure
  config_entrypoint.public_send(:"#{option_name}=", old_value)
end

def with_preview_paths(new_value, config_entrypoint: TestEngine::Engine.config.view_component, &block)
  old_value = config_entrypoint.previews.paths
  config_entrypoint.previews.paths = new_value
  yield
ensure
  config_entrypoint.previews.paths = old_value
end