class RSpec::SleepingKingStudios::Deferred::Calls::Hook
Value object representing a deferred RSpec
example.
Constants
- VALID_METHOD_NAMES
- VALID_SCOPES
Public Instance Methods
Source
# File lib/rspec/sleeping_king_studios/deferred/calls/hook.rb, line 20 def scope arguments.first&.intern end
@return [Symbol] the scope of the hook.
Private Instance Methods
Source
# File lib/rspec/sleeping_king_studios/deferred/calls/hook.rb, line 26 def validate_block! return if block raise ArgumentError, 'no block given' end
Source
# File lib/rspec/sleeping_king_studios/deferred/calls/hook.rb, line 32 def validate_method_name! return if VALID_METHOD_NAMES.include?(method_name) raise ArgumentError, "invalid hook method #{method_name.inspect}" end
Source
# File lib/rspec/sleeping_king_studios/deferred/calls/hook.rb, line 38 def validate_parameters! super validate_block! validate_method_name! validate_scope! end
Calls superclass method
RSpec::SleepingKingStudios::Deferred::Call#validate_parameters!
Source
# File lib/rspec/sleeping_king_studios/deferred/calls/hook.rb, line 46 def validate_scope! # rubocop:disable Metrics/MethodLength tools.assertions.validate_name(arguments.first, as: :scope) if method_name == :around return if scope == :each || scope == :example # rubocop:disable Style/MultipleComparison raise ArgumentError, 'scope for an :around hook must be :example' else return if VALID_SCOPES.include?(scope) message = "scope for a #{method_name.inspect} hook must be :context, :each, " \ 'or :example' raise ArgumentError, message end end