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, 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
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, 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.
94 95 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 |
# File 'lib/toys/templates/minitest.rb', line 94 def initialize(name: nil, minitest: nil, minitest_mock: nil, minitest_focus: nil, minitest_rg: nil, gems: 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) 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.
259 260 261 |
# File 'lib/toys/templates/minitest.rb', line 259 def bundler=(value) @bundler = value end |
#context_directory=(value) ⇒ String
Custom context directory for this tool.
246 247 248 |
# File 'lib/toys/templates/minitest.rb', line 246 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.
214 215 216 |
# File 'lib/toys/templates/minitest.rb', line 214 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.
205 206 207 |
# File 'lib/toys/templates/minitest.rb', line 205 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.
271 272 273 |
# File 'lib/toys/templates/minitest.rb', line 271 def mt_compat=(value) @mt_compat = value end |
#name=(value) ⇒ String
Name of the tool to create.
131 132 133 |
# File 'lib/toys/templates/minitest.rb', line 131 def name=(value) @name = value end |
#seed=(value) ⇒ Integer?
The random seed, or nil if not specified.
222 223 224 |
# File 'lib/toys/templates/minitest.rb', line 222 def seed=(value) @seed = value end |
#verbose=(value) ⇒ boolean
Whether to produce verbose output.
230 231 232 |
# File 'lib/toys/templates/minitest.rb', line 230 def verbose=(value) @verbose = value end |
#warnings=(value) ⇒ boolean
Whether to run tests with Ruby warnings.
238 239 240 |
# File 'lib/toys/templates/minitest.rb', line 238 def warnings=(value) @warnings = value end |
Instance Method Details
#minitest=(value) ⇒ Object
Version requirements for the minitest gem. Used if bundler is not used.
If set to true or nil, a default version requirement is used.
158 159 160 |
# File 'lib/toys/templates/minitest.rb', line 158 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.
182 183 184 |
# File 'lib/toys/templates/minitest.rb', line 182 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.
170 171 172 |
# File 'lib/toys/templates/minitest.rb', line 170 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.
194 195 196 |
# File 'lib/toys/templates/minitest.rb', line 194 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.
145 146 147 148 149 150 |
# File 'lib/toys/templates/minitest.rb', line 145 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.
283 284 285 286 |
# File 'lib/toys/templates/minitest.rb', line 283 def use_bundler(**opts) @bundler = opts self end |