class Toys::Templates::Rspec
A template for tools that run rspec
Constants
- DEFAULT_FORMAT
Default format code @return [String]
- DEFAULT_GEM_VERSION_REQUIREMENTS
Default version requirements for the rspec gem. @return [Array<String>]
- DEFAULT_LIBS
Default set of library paths @return [Array<String>]
- DEFAULT_ORDER
Default order type @return [String]
- DEFAULT_PATTERN
Default spec file glob @return [String]
- DEFAULT_TOOL_NAME
Default tool name @return [String]
Attributes
Whether to enable full backtraces.
@param value [Boolean] @return [Boolean]
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](dazuma.github.io/toys/gems/toys-core/latest/Toys/StandardMixins/Bundler) for information on the options that can be passed.
@param value [Boolean,Hash] @return [Boolean,Hash]
Custom context directory for this tool.
@param value [String] @return [String]
The formatter code. If set to `nil`, defaults to {DEFAULT_FORMAT}.
@param value [String,nil] @return [String,nil]
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.
@param value [String,Array<String>,nil] @return [String,Array<String>,nil]
An array of directories to add to the Ruby require path. If set to `nil`, defaults to {DEFAULT_LIBS}.
@param value [Array<String>,nil] @return [Array<String>,nil]
Name of the tool to create.
@param value [String] @return [String]
Path to the custom options file, or `nil` for none.
@param value [String,nil] @return [String,nil]
The order in which to run examples. If set to `nil`, defaults to {DEFAULT_ORDER}.
@param value [String,nil] @return [String,nil]
Path to a file to write output to. If set to `nil`, writes output to standard out.
@param value [String,nil] @return [String,nil]
A glob indicating the spec files to load. If set to `nil`, defaults to {DEFAULT_PATTERN}.
@param value [String,nil] @return [String,nil]
Whether to run with Ruby warnings.
@param value [Boolean] @return [Boolean]
Public Class Methods
Create the template settings for the RSpec template.
@param name [String] Name of the tool to create. Defaults to
{DEFAULT_TOOL_NAME}.
@param gem_version
[String,Array<String>] Version requirements for
the rspec gem. Defaults to {DEFAULT_GEM_VERSION_REQUIREMENTS}.
@param libs [Array<String>] An array of library paths to add to the
ruby require path. Defaults to {DEFAULT_LIBS}.
@param options [String] The path to a custom options file, if any. @param order [String] The order in which to run examples. Default is
{DEFAULT_ORDER}.
@param format [String] The formatter code. Default is {DEFAULT_FORMAT}. @param out [String] Write output to a file instead of stdout. @param backtrace [Boolean] Enable full backtrace (default is false). @param pattern [String] A glob indicating the spec files to load.
Defaults to {DEFAULT_PATTERN}.
@param warnings [Boolean] If true, runs specs with Ruby warnings.
Defaults to true.
@param bundler [Boolean,Hash] 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](https://dazuma.github.io/toys/gems/toys-core/latest/Toys/StandardMixins/Bundler) for information on available options.
@param context_directory
[String] A custom context directory to use
when executing this tool.
# File lib/toys/templates/rspec.rb, line 74 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, context_directory: nil) @name = name @gem_version = gem_version @libs = libs @options = options @order = order @format = format @out = out @backtrace = backtrace @pattern = pattern @warnings = warnings @bundler = bundler @context_directory = context_directory end
Public Instance Methods
@private
# File lib/toys/templates/rspec.rb, line 267 def bundler_settings if @bundler && !@bundler.is_a?(::Hash) {} else @bundler end end
@private
# File lib/toys/templates/rspec.rb, line 257 def format @format || DEFAULT_FORMAT end
@private
# File lib/toys/templates/rspec.rb, line 241 def gem_version return Array(@gem_version) if @gem_version @bundler ? [] : DEFAULT_GEM_VERSION_REQUIREMENTS end
@private
# File lib/toys/templates/rspec.rb, line 247 def libs @libs ? Array(@libs) : DEFAULT_LIBS end
@private
# File lib/toys/templates/rspec.rb, line 236 def name @name || DEFAULT_TOOL_NAME end
@private
# File lib/toys/templates/rspec.rb, line 252 def order @order || DEFAULT_ORDER end
@private
# File lib/toys/templates/rspec.rb, line 262 def pattern @pattern || DEFAULT_PATTERN end
Activate bundler for this tool.
See the documentation for the [bundler mixin](dazuma.github.io/toys/gems/toys-core/latest/Toys/StandardMixins/Bundler) for information on the options that can be passed.
@param opts [keywords] Options for bundler @return [self]
# File lib/toys/templates/rspec.rb, line 219 def use_bundler(**opts) @bundler = opts self end