Sha256: 2326e19a5e0509acc78e82fb4857a8e0b0c8e5508f5b37f16f4ddb2c87dbd23a
Contents?: true
Size: 1.52 KB
Versions: 44
Compression:
Stored size: 1.52 KB
Contents
module RSpec module Matchers module BuiltIn # @api private # Provides the implementation for `satisfy`. # Not intended to be instantiated directly. class Satisfy < BaseMatcher def initialize(description=nil, &block) @description = description @block = block end # @private def matches?(actual, &block) @block = block if block @actual = actual @block.call(actual) end # @private def description @description ||= "satisfy #{block_representation}" end # @api private # @return [String] def failure_message "expected #{actual_formatted} to #{description}" end # @api private # @return [String] def failure_message_when_negated "expected #{actual_formatted} not to #{description}" end private # rubocop:disable Lint/UselessAccessModifier if RSpec::Support::RubyFeatures.ripper_supported? def block_representation if (block_snippet = extract_block_snippet) "expression `#{block_snippet}`" else 'block' end end def extract_block_snippet return nil unless @block Expectations::BlockSnippetExtractor.try_extracting_single_line_body_of(@block, matcher_name) end else def block_representation 'block' end end end end end end
Version data entries
44 entries across 39 versions & 19 rubygems