Class: Toys::Templates::Minitest

Inherits:
Object
  • Object
show all
Includes:
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 the minitest gem.

Returns:

  • (Array<String>)
["~> 5.0"].freeze
DEFAULT_TOOL_NAME =

Default tool name

Returns:

  • (String)
"test"
DEFAULT_LIBS =

Default set of library paths

Returns:

  • (Array<String>)
["lib"].freeze
DEFAULT_FILES =

Default set of test file globs

Returns:

  • (Array<String>)
["test/**/test*.rb"].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, gem_version: nil, libs: nil, files: nil, seed: nil, verbose: false, warnings: true, bundler: false) ⇒ Minitest

Create the template settings for the Minitest template.

Parameters:

  • name (String) (defaults to: nil)

    Name of the tool to create. Defaults to DEFAULT_TOOL_NAME.

  • gem_version (String, Array<String>) (defaults to: nil)

    Version requirements for the minitest gem. Optional. If not provided, uses the bundled version if bundler is enabled, or defaults to DEFAULT_GEM_VERSION_REQUIREMENTS if bundler is not enabled.

  • libs (Array<String>) (defaults to: nil)

    An array of library paths to add to the ruby require path. Defaults to DEFAULT_LIBS.

  • files (Array<String>) (defaults to: nil)

    An array of globs indicating the test files to load. Defaults to DEFAULT_FILES.

  • seed (Integer) (defaults to: nil)

    The random seed, if any. Optional.

  • verbose (Boolean) (defaults to: false)

    Whether to produce verbose output. Defaults to false.

  • warnings (Boolean) (defaults to: true)

    If true, runs tests with Ruby warnings. Defaults to true.

  • bundler (Boolean, Hash) (defaults to: false)

    If false (the default), bundler is not enabled for this tool. If true or a Hash of options, bundler is enabled. See the documentation for the bundler mixin for information on available options.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/toys/templates/minitest.rb', line 59

def initialize(name: nil,
               gem_version: nil,
               libs: nil,
               files: nil,
               seed: nil,
               verbose: false,
               warnings: true,
               bundler: false)
  @name = name
  @gem_version = gem_version
  @libs = libs
  @files = files
  @seed = seed
  @verbose = verbose
  @warnings = warnings
  @bundler = bundler
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.

Parameters:

  • value (Boolean, Hash)

Returns:

  • (Boolean, Hash)


149
150
151
# File 'lib/toys/templates/minitest.rb', line 149

def bundler=(value)
  @bundler = value
end

#files=(value) ⇒ String, ...

An array of globs indicating the test files to load. If set to nil, defaults to DEFAULT_FILES.

Parameters:

  • value (String, Array<String>, nil)

Returns:

  • (String, Array<String>, nil)


112
113
114
# File 'lib/toys/templates/minitest.rb', line 112

def files=(value)
  @files = value
end

#gem_version=(value) ⇒ String, ...

Version requirements for the minitest gem. If set to nil, uses the bundled version if bundler is enabled, or defaults to DEFAULT_GEM_VERSION_REQUIREMENTS if bundler is not enabled.

Parameters:

  • value (String, Array<String>, nil)

Returns:

  • (String, Array<String>, nil)


94
95
96
# File 'lib/toys/templates/minitest.rb', line 94

def gem_version=(value)
  @gem_version = 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.

Parameters:

  • value (String, Array<String>, nil)

Returns:

  • (String, Array<String>, nil)


103
104
105
# File 'lib/toys/templates/minitest.rb', line 103

def libs=(value)
  @libs = value
end

#name=(value) ⇒ String

Name of the tool to create.

Parameters:

  • value (String)

Returns:

  • (String)


83
84
85
# File 'lib/toys/templates/minitest.rb', line 83

def name=(value)
  @name = value
end

#seed=(value) ⇒ Integer?

The random seed, or nil if not specified.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


120
121
122
# File 'lib/toys/templates/minitest.rb', line 120

def seed=(value)
  @seed = value
end

#verbose=(value) ⇒ Boolean

Whether to produce verbose output.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


128
129
130
# File 'lib/toys/templates/minitest.rb', line 128

def verbose=(value)
  @verbose = value
end

#warnings=(value) ⇒ Boolean

Whether to run tests with Ruby warnings.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


136
137
138
# File 'lib/toys/templates/minitest.rb', line 136

def warnings=(value)
  @warnings = value
end

Instance Method Details

#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.

Parameters:

  • opts (keywords)

    Options for bundler

Returns:

  • (self)


161
162
163
164
# File 'lib/toys/templates/minitest.rb', line 161

def use_bundler(**opts)
  @bundler = opts
  self
end