Class: Toys::Templates::Minitest
- Inherits:
-
Object
- Object
- Toys::Templates::Minitest
- Includes:
- Toys::Template
- Defined in:
- lib/toys/templates/minitest.rb
Overview
A template for tools that run minitest
Constant Summary collapse
- DEFAULT_GEM_VERSION_REQUIREMENTS =
Default version requirements for gem names.
{ "minitest" => [">= 5.0", "< 7"].freeze, "minitest-mock" => ["~> 5.27"].freeze, "minitest-focus" => ["~> 1.4", ">= 1.4.1"].freeze, "minitest-rg" => ["~> 5.4"].freeze, }.freeze
- DEFAULT_TOOL_NAME =
Default tool name
"test"- DEFAULT_LIBS =
Default set of library paths
["lib"].freeze
- DEFAULT_FILES =
Default set of test file globs
["test/**/test_*.rb", "test/**/*_test.rb"].freeze
Instance Attribute Summary collapse
-
#bundler ⇒ boolean, Hash
writeonly
Set the bundler state and options for this tool.
-
#context_directory ⇒ String
writeonly
Custom context directory for this tool.
-
#files ⇒ String, ...
writeonly
An array of globs indicating the test files to load.
-
#libs ⇒ String, ...
writeonly
An array of library paths to add to the ruby require path.
-
#mt_compat ⇒ true, ...
writeonly
Adjust the
MT_COMPATenvironment variable when running tests. -
#name ⇒ String
writeonly
Name of the tool to create.
-
#seed ⇒ Integer?
writeonly
The random seed, or
nilif not specified. -
#verbose ⇒ boolean
writeonly
Whether to produce verbose output.
-
#warnings ⇒ boolean
writeonly
Whether to run tests with Ruby warnings.
Instance Method Summary collapse
-
#initialize(name: nil, minitest: nil, minitest_mock: nil, minitest_focus: nil, minitest_rg: nil, gems: nil, gem_version: nil, libs: nil, files: nil, seed: nil, verbose: false, warnings: true, bundler: false, mt_compat: nil, context_directory: nil) ⇒ Minitest
constructor
Create the template settings for the Minitest template.
-
#minitest=(value) ⇒ Object
(also: #gem_version=)
Version requirements for the minitest gem.
-
#minitest_focus=(value) ⇒ Object
Version requirements for the minitest-focus gem.
-
#minitest_mock=(value) ⇒ Object
Version requirements for the minitest-mock gem.
-
#minitest_rg=(value) ⇒ Object
Version requirements for the minitest-rg gem.
-
#update_gems(gems) ⇒ self
Update the gems and version requirements that are used if bundler is not enabled.
-
#use_bundler(**opts) ⇒ self
Use bundler for this tool.
Methods included from Toys::Template
Constructor Details
#initialize(name: nil, minitest: nil, minitest_mock: nil, minitest_focus: nil, minitest_rg: nil, gems: nil, gem_version: nil, libs: nil, files: nil, seed: nil, verbose: false, warnings: true, bundler: false, mt_compat: nil, context_directory: nil) ⇒ Minitest
Create the template settings for the Minitest template.
Note that arguments related to gem and bundler settings are defaults that can be overridden by command line arguments.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/toys/templates/minitest.rb', line 96 def initialize(name: nil, minitest: nil, minitest_mock: nil, minitest_focus: nil, minitest_rg: nil, gems: nil, gem_version: nil, libs: nil, files: nil, seed: nil, verbose: false, warnings: true, bundler: false, mt_compat: nil, context_directory: nil) @name = name @libs = libs @files = files @seed = seed @verbose = verbose @warnings = warnings @bundler = bundler @mt_compat = mt_compat @context_directory = context_directory @gem_dependencies = {} update_version_spec("minitest", minitest || gem_version) update_version_spec("minitest-mock", minitest_mock) update_version_spec("minitest-focus", minitest_focus) update_version_spec("minitest-rg", minitest_rg) update_gems(gems) if gems end |
Instance Attribute Details
#bundler=(value) ⇒ boolean, Hash (writeonly)
Set the bundler state and options for this tool.
Pass false to disable bundler. Pass true or a hash of options to
enable bundler. See the documentation for the
bundler mixin
for information on the options that can be passed.
263 264 265 |
# File 'lib/toys/templates/minitest.rb', line 263 def bundler=(value) @bundler = value end |
#context_directory=(value) ⇒ String
Custom context directory for this tool.
250 251 252 |
# File 'lib/toys/templates/minitest.rb', line 250 def context_directory=(value) @context_directory = value end |
#files=(value) ⇒ String, ...
An array of globs indicating the test files to load.
If set to nil, defaults to DEFAULT_FILES.
218 219 220 |
# File 'lib/toys/templates/minitest.rb', line 218 def files=(value) @files = value end |
#libs=(value) ⇒ String, ...
An array of library paths to add to the ruby require path.
If set to nil, defaults to DEFAULT_LIBS.
209 210 211 |
# File 'lib/toys/templates/minitest.rb', line 209 def libs=(value) @libs = value end |
#mt_compat=(value) ⇒ true, ...
Adjust the MT_COMPAT environment variable when running tests. This
setting may be necessary for certain older Minitest plugins.
Pass true to enable compat mode, false to disable it, or nil to
use any ambient setting from the current environment.
275 276 277 |
# File 'lib/toys/templates/minitest.rb', line 275 def mt_compat=(value) @mt_compat = value end |
#name=(value) ⇒ String
Name of the tool to create.
134 135 136 |
# File 'lib/toys/templates/minitest.rb', line 134 def name=(value) @name = value end |
#seed=(value) ⇒ Integer?
The random seed, or nil if not specified.
226 227 228 |
# File 'lib/toys/templates/minitest.rb', line 226 def seed=(value) @seed = value end |
#verbose=(value) ⇒ boolean
Whether to produce verbose output.
234 235 236 |
# File 'lib/toys/templates/minitest.rb', line 234 def verbose=(value) @verbose = value end |
#warnings=(value) ⇒ boolean
Whether to run tests with Ruby warnings.
242 243 244 |
# File 'lib/toys/templates/minitest.rb', line 242 def warnings=(value) @warnings = value end |
Instance Method Details
#minitest=(value) ⇒ Object Also known as: gem_version=
Version requirements for the minitest gem. Used if bundler is not used.
If set to true or nil, a default version requirement is used.
161 162 163 |
# File 'lib/toys/templates/minitest.rb', line 161 def minitest=(value) update_version_spec("minitest", value) end |
#minitest_focus=(value) ⇒ Object
Version requirements for the minitest-focus gem. Used if bundler is not
used.
If set to true, a default version requirement is used.
If set to nil, minitest-focus is removed from the gem dependencies.
186 187 188 |
# File 'lib/toys/templates/minitest.rb', line 186 def minitest_focus=(value) update_version_spec("minitest-focus", value) end |
#minitest_mock=(value) ⇒ Object
Version requirements for the minitest-mock gem. Used if bundler is not
used.
If set to true, a default version requirement is used.
If set to nil, minitest-mock is removed from the gem dependencies.
174 175 176 |
# File 'lib/toys/templates/minitest.rb', line 174 def minitest_mock=(value) update_version_spec("minitest-mock", value) end |
#minitest_rg=(value) ⇒ Object
Version requirements for the minitest-rg gem. Used if bundler is not
used.
If set to true, a default version requirement is used.
If set to nil, minitest-rg is removed from the gem dependencies.
198 199 200 |
# File 'lib/toys/templates/minitest.rb', line 198 def minitest_rg=(value) update_version_spec("minitest-rg", value) end |
#update_gems(gems) ⇒ self
Update the gems and version requirements that are used if bundler is not enabled.
148 149 150 151 152 153 |
# File 'lib/toys/templates/minitest.rb', line 148 def update_gems(gems) gems.each do |gem_name, version_requirements| update_version_spec(gem_name, version_requirements) end self end |
#use_bundler(**opts) ⇒ self
Use bundler for this tool.
See the documentation for the bundler mixin for information on the options that can be passed.
287 288 289 290 |
# File 'lib/toys/templates/minitest.rb', line 287 def use_bundler(**opts) @bundler = opts self end |