class Central::Devtools::Project::Initializer::Rspec
Requires all shared specs in a project's spec_helper Also installs a configurable unit test timeout
Public Class Methods
call(project)
click to toggle source
Call initializer for project
@param [Project] project @return [self] @api private
# File lib/central/devtools/project/initializer/rspec.rb, line 17 def self.call(project) new(project).__send__(:call) self end
Private Instance Methods
call()
click to toggle source
Setup RSpec for project
@return [self] @api private
# File lib/central/devtools/project/initializer/rspec.rb, line 28 def call require_shared_spec_files enable_unit_test_timeout end
enable_unit_test_timeout()
click to toggle source
Timeout unit tests that take longer than configured amount of time
@param [Numeric] timeout @return [undefined] @raise [Timeout::Error]
raised when the times are outside the timeout
@api private
# File lib/central/devtools/project/initializer/rspec.rb, line 40 def enable_unit_test_timeout timeout = project.devtools.unit_test_timeout RSpec.configuration.around(file_path: UNIT_TEST_PATH_REGEXP) do |example| Timeout.timeout(timeout, &example) end end
require_files(dir)
click to toggle source
Require files with pattern
@param [Pathname] dir
the directory containing the files to require
@return [self] @api private
# File lib/central/devtools/project/initializer/rspec.rb, line 63 def require_files(dir) Dir.glob(dir.join(SHARED_SPEC_PATTERN)).each(&Kernel.method(:require)) end