Class: Toys::Templates::Rspec
- Inherits:
-
Object
- Object
- Toys::Templates::Rspec
- Includes:
- Template
- Defined in:
- lib/toys/templates/rspec.rb
Overview
A template for tools that run rspec
Constant Summary collapse
- DEFAULT_GEM_VERSION_REQUIREMENTS =
Default version requirements for the rspec gem.
["~> 3.1"].freeze
- DEFAULT_TOOL_NAME =
Default tool name
"spec"
- DEFAULT_LIBS =
Default set of library paths
["lib"].freeze
- DEFAULT_ORDER =
Default order type
"defined"
- DEFAULT_FORMAT =
Default format code
"p"
- DEFAULT_PATTERN =
Default spec file glob
"spec/**/*_spec.rb"
Instance Attribute Summary collapse
-
#backtrace ⇒ Boolean
writeonly
Whether to enable full backtraces.
-
#bundler ⇒ Boolean, Hash
writeonly
Set the bundler state and options for this tool.
-
#format ⇒ String?
writeonly
The formatter code.
-
#gem_version ⇒ String, ...
writeonly
Version requirements for the rspec gem.
-
#libs ⇒ Array<String>?
writeonly
An array of directories to add to the Ruby require path.
-
#name ⇒ String
writeonly
Name of the tool to create.
-
#options ⇒ String?
writeonly
Path to the custom options file, or
nil
for none. -
#order ⇒ String?
writeonly
The order in which to run examples.
-
#out ⇒ String?
writeonly
Path to a file to write output to.
-
#pattern ⇒ String?
writeonly
A glob indicating the spec files to load.
-
#warnings ⇒ Boolean
writeonly
Whether to run with Ruby warnings.
Instance Method Summary collapse
-
#initialize(name: nil, gem_version: nil, libs: nil, options: nil, order: nil, format: nil, out: nil, backtrace: false, pattern: nil, warnings: true, bundler: false) ⇒ Rspec
constructor
Create the template settings for the RSpec template.
-
#use_bundler(**opts) ⇒ self
Activate bundler for this tool.
Constructor Details
#initialize(name: nil, gem_version: nil, libs: nil, options: nil, order: nil, format: nil, out: nil, backtrace: false, pattern: nil, warnings: true, bundler: false) ⇒ Rspec
Create the template settings for the RSpec template.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/toys/templates/rspec.rb', line 72 def initialize(name: nil, gem_version: nil, libs: nil, options: nil, order: nil, format: nil, out: nil, backtrace: false, pattern: nil, warnings: true, bundler: false) @name = name @gem_version = gem_version @libs = libs @options = @order = order @format = format @out = out @backtrace = backtrace @pattern = pattern @warnings = warnings @bundler = bundler end |
Instance Attribute Details
#backtrace=(value) ⇒ Boolean
Whether to enable full backtraces.
165 166 167 |
# File 'lib/toys/templates/rspec.rb', line 165 def backtrace=(value) @backtrace = value end |
#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.
195 196 197 |
# File 'lib/toys/templates/rspec.rb', line 195 def bundler=(value) @bundler = value end |
#format=(value) ⇒ String?
The formatter code.
If set to nil
, defaults to DEFAULT_FORMAT.
148 149 150 |
# File 'lib/toys/templates/rspec.rb', line 148 def format=(value) @format = value end |
#gem_version=(value) ⇒ String, ...
Version requirements for the rspec 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.
113 114 115 |
# File 'lib/toys/templates/rspec.rb', line 113 def gem_version=(value) @gem_version = value end |
#libs=(value) ⇒ Array<String>?
An array of directories to add to the Ruby require path.
If set to nil
, defaults to DEFAULT_LIBS.
122 123 124 |
# File 'lib/toys/templates/rspec.rb', line 122 def libs=(value) @libs = value end |
#name=(value) ⇒ String
Name of the tool to create.
102 103 104 |
# File 'lib/toys/templates/rspec.rb', line 102 def name=(value) @name = value end |
#options=(value) ⇒ String?
Path to the custom options file, or nil
for none.
130 131 132 |
# File 'lib/toys/templates/rspec.rb', line 130 def (value) @options = value end |
#order=(value) ⇒ String?
The order in which to run examples.
If set to nil
, defaults to DEFAULT_ORDER.
139 140 141 |
# File 'lib/toys/templates/rspec.rb', line 139 def order=(value) @order = value end |
#out=(value) ⇒ String?
Path to a file to write output to.
If set to nil
, writes output to standard out.
157 158 159 |
# File 'lib/toys/templates/rspec.rb', line 157 def out=(value) @out = value end |
#pattern=(value) ⇒ String?
A glob indicating the spec files to load.
If set to nil
, defaults to DEFAULT_PATTERN.
174 175 176 |
# File 'lib/toys/templates/rspec.rb', line 174 def pattern=(value) @pattern = value end |
#warnings=(value) ⇒ Boolean
Whether to run with Ruby warnings.
182 183 184 |
# File 'lib/toys/templates/rspec.rb', line 182 def warnings=(value) @warnings = value end |
Instance Method Details
#use_bundler(**opts) ⇒ self
Activate bundler for this tool.
See the documentation for the bundler mixin for information on the options that can be passed.
207 208 209 210 |
# File 'lib/toys/templates/rspec.rb', line 207 def use_bundler(**opts) @bundler = opts self end |