Sha256: 1530ff44f692296cdf0fb2a14001df58b3c5166af5ec63e3f23bcef91683fd09

Contents?: true

Size: 1.16 KB

Versions: 198

Compression:

Stored size: 1.16 KB

Contents

module RSpec
  module Matchers
    class << self
      # @private
      attr_accessor :last_matcher, :last_expectation_handler
    end

    # @api private
    # Used by rspec-core to clear the state used to generate
    # descriptions after an example.
    def self.clear_generated_description
      self.last_matcher = nil
      self.last_expectation_handler = nil
    end

    # @api private
    # Generates an an example description based on the last expectation.
    # Used by rspec-core's one-liner syntax.
    def self.generated_description
      return nil if last_expectation_handler.nil?
      "#{last_expectation_handler.verb} #{last_description}"
    end

  private

    def self.last_description
      last_matcher.respond_to?(:description) ? last_matcher.description : <<-MESSAGE
When you call a matcher in an example without a String, like this:

specify { expect(object).to matcher }

or this:

it { is_expected.to matcher }

RSpec expects the matcher to have a #description method. You should either
add a String to the example this matcher is being used in, or give it a
description method. Then you won't have to suffer this lengthy warning again.
MESSAGE
    end
  end
end

Version data entries

198 entries across 180 versions & 54 rubygems

Version Path
opal-rspec-0.8.0 rspec-expectations/upstream/lib/rspec/matchers/generated_descriptions.rb
opal-rspec-0.8.0.alpha3 rspec-expectations/upstream/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
opal-rspec-0.8.0.alpha2 rspec-expectations/upstream/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb
opal-rspec-0.8.0.alpha1 rspec-expectations/upstream/lib/rspec/matchers/generated_descriptions.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/rspec-expectations-3.5.0/lib/rspec/matchers/generated_descriptions.rb