Class: Toys::Templates::Minitest

Inherits:
Object
  • Object
show all
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 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

Methods included from Toys::Template

create

Constructor Details

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

  • context_directory (String) (defaults to: nil)

    A custom context directory to use when executing this tool.



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

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


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

def bundler=(value)
  @bundler = value
end

#context_directory=(value) ⇒ String

Custom context directory for this tool.

Parameters:

  • value (String)

Returns:

  • (String)


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

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.

Parameters:

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

Returns:

  • (String, Array<String>, nil)


116
117
118
# File 'lib/toys/templates/minitest.rb', line 116

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)


98
99
100
# File 'lib/toys/templates/minitest.rb', line 98

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)


107
108
109
# File 'lib/toys/templates/minitest.rb', line 107

def libs=(value)
  @libs = value
end

#name=(value) ⇒ String

Name of the tool to create.

Parameters:

  • value (String)

Returns:

  • (String)


87
88
89
# File 'lib/toys/templates/minitest.rb', line 87

def name=(value)
  @name = value
end

#seed=(value) ⇒ Integer?

The random seed, or nil if not specified.

Parameters:

  • value (Integer, nil)

Returns:

  • (Integer, nil)


124
125
126
# File 'lib/toys/templates/minitest.rb', line 124

def seed=(value)
  @seed = value
end

#verbose=(value) ⇒ Boolean

Whether to produce verbose output.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


132
133
134
# File 'lib/toys/templates/minitest.rb', line 132

def verbose=(value)
  @verbose = value
end

#warnings=(value) ⇒ Boolean

Whether to run tests with Ruby warnings.

Parameters:

  • value (Boolean)

Returns:

  • (Boolean)


140
141
142
# File 'lib/toys/templates/minitest.rb', line 140

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)


173
174
175
176
# File 'lib/toys/templates/minitest.rb', line 173

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