Module: Minitest

Defined in:
lib/minitest/holdify_plugin.rb

Overview

Implement the minitest plugin

Defined Under Namespace

Modules: Assertions Classes: Assertion, Test

Class Method Summary collapse

Class Method Details

.plugin_holdify_init(options) ⇒ Object

Register the after_run hook to persist all data



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/minitest/holdify_plugin.rb', line 31

def self.plugin_holdify_init(options)
  # :nocov:
  git         = system('git --version', out: File::NULL, err: File::NULL)
  Holdify.pwd = git ? `git rev-parse --show-toplevel`.strip : Dir.pwd
  # :nocov:

  Holdify.reconcile = options[:holdify_reconcile]
  Holdify.quiet     = options[:holdify_quiet]
  Holdify.git_diff  = git unless options[:holdify_no_git_diff]
  Holdify.color     = !ENV.key?('NO_COLOR') unless options[:holdify_no_color]
  Holdify.rel_paths = true unless options[:holdify_absolute_paths]
  Holdify.store_ext = options[:holdify_store_ext] || '.yaml'

  Minitest.after_run do
    Holdify.persist_stores!
    Holdify.warn_fresh_values
  end
end

.plugin_holdify_options(opts, options) ⇒ Object

Set the Holdify options



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/minitest/holdify_plugin.rb', line 8

def self.plugin_holdify_options(opts, options)
  opts.on '--holdify-reconcile', 'Reconcile the held values with the new ones (enables quiet)' do
    options[:holdify_reconcile] = true
    options[:holdify_quiet]     = true
  end
  opts.on '--holdify-quiet', 'Skip the warning on storing a new value' do
    options[:holdify_quiet] = true
  end
  opts.on '--holdify-no-git-diff', 'Disable git-diff' do
    options[:holdify_no_git_diff] = true
  end
  opts.on '--holdify-no-color', 'Disable colored output' do
    options[:holdify_no_color] = true
  end
  opts.on '--holdify-absolute-paths', 'Disable relative paths in file references' do
    options[:holdify_absolute_paths] = true
  end
  opts.on '--holdify-store-ext EXT', 'The yaml store extension (default .yaml)' do |ext|
    options[:holdify_store_ext] = ext
  end
end