Sha256: e073a7a2fdd3aa01c85207bb643135827637e8f7a910dd0de28ccb8e911ba460

Contents?: true

Size: 1.52 KB

Versions: 1390

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

        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
          # :nocov:
          def block_representation
            'block'
          end
          # :nocov:
        end
      end
    end
  end
end

Version data entries

1,390 entries across 1,389 versions & 12 rubygems

Version Path
cybrid_api_id_ruby-0.123.310 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.123.310 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.123.310 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.123.309 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.123.309 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.123.309 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.123.307 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.123.307 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.123.307 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.123.306 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.123.306 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.123.306 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.123.305 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.123.305 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.123.305 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.123.303 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.123.303 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_id_ruby-0.123.303 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_bank_ruby-0.123.302 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb
cybrid_api_organization_ruby-0.123.302 vendor/bundle/ruby/3.3.0/gems/rspec-expectations-3.13.3/lib/rspec/matchers/built_in/satisfy.rb