Sha256: 0483e105da9e2887b3156764a3046d977e2a44ca99a2fdc84f48d29f6d1cfdbb

Contents?: true

Size: 1.48 KB

Versions: 6160

Compression:

Stored size: 1.48 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

        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

6,160 entries across 6,091 versions & 84 rubygems

Version Path
cybrid_api_organization_ruby-0.119.6 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.119.6 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.119.6 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
moneykit-0.1.11 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.12.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.119.4 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.119.4 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.119.4 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.119.2 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.119.2 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.119.2 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.119.1 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.119.1 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.119.1 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.118.125 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.118.125 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.118.125 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.118.124 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.118.124 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.118.124 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.118.121 vendor/bundle/ruby/3.2.0/gems/rspec-expectations-3.13.1/lib/rspec/matchers/built_in/satisfy.rb