class Develry::Project::Initializer::Rspec
Requires all shared specs in a project's spec_helper Also installs a configurable unit test timeout
Attributes
spec_root[R]
The spec root
@return [Pathname]
@api private
unit_test_timeout[R]
The unit test timeout
@return [Numeric]
@api private
Public Class Methods
call(project)
click to toggle source
Initialize RSpec for project
@param [Project] project
the project to initialize
@return [Rspec]
@api private
# File lib/develry/project/initializer/rspec.rb, line 23 def self.call(project) new(project).call end
new(project)
click to toggle source
Initialize a new instance
@param [Project] project
the project to initialize
@param [Numeric] unit_test_timeout
the maximum time a single unit test can take
@return [undefined]
@api private
Calls superclass method
# File lib/develry/project/initializer/rspec.rb, line 54 def initialize(project) super @spec_root = project.spec_root @unit_test_timeout = project.unit_test_timeout end
require_files(directory)
click to toggle source
# File lib/develry/project/initializer/rspec.rb, line 11 def self.require_files(directory) Develry.require_files(directory, SHARED_SPEC_PATTERN) end
Public Instance Methods
call()
click to toggle source
Setup RSpec for {#project}
@return [self]
@api private
# File lib/develry/project/initializer/rspec.rb, line 65 def call require 'rspec' require_shared_spec_files enable_unit_test_timeout unless Develry.jit? self end
Private Instance Methods
enable_unit_test_timeout()
click to toggle source
Timeout unit tests that take longer than 1/10th of a second
@param [Numeric] timeout
@return [undefined]
@raise [Timeout::Error]
raised when the times are outside the timeout
@api private
# File lib/develry/project/initializer/rspec.rb, line 85 def enable_unit_test_timeout timeout = unit_test_timeout # support the closure RSpec.configuration.around file_path: UNIT_TEST_PATH_REGEXP do |example| Timeout.timeout(timeout, &example) end end
require_files(directory)
click to toggle source
# File lib/develry/project/initializer/rspec.rb, line 97 def require_files(directory) self.class.require_files(directory) end