class RSpec::Matchers::BuiltIn::Satisfy
@api private Provides the implementation for ‘satisfy`. Not intended to be instantiated directly.
Public Class Methods
Source
# File lib/rspec/matchers/built_in/satisfy.rb, line 8 def initialize(description=nil, &block) @description = description @block = block end
Public Instance Methods
Source
# File lib/rspec/matchers/built_in/satisfy.rb, line 21 def description @description ||= "satisfy #{block_representation}" end
@private
Source
# File lib/rspec/matchers/built_in/satisfy.rb, line 27 def failure_message "expected #{actual_formatted} to #{description}" end
@api private @return [String]
Source
# File lib/rspec/matchers/built_in/satisfy.rb, line 33 def failure_message_when_negated "expected #{actual_formatted} not to #{description}" end
@api private @return [String]
Source
# File lib/rspec/matchers/built_in/satisfy.rb, line 14 def matches?(actual, &block) @block = block if block @actual = actual @block.call(actual) end
@private
Private Instance Methods
Source
# File lib/rspec/matchers/built_in/satisfy.rb, line 40 def block_representation if (block_snippet = extract_block_snippet) "expression `#{block_snippet}`" else 'block' end end
Source
# File lib/rspec/matchers/built_in/satisfy.rb, line 48 def extract_block_snippet return nil unless @block Expectations::BlockSnippetExtractor.try_extracting_single_line_body_of(@block, matcher_name) end