Sha256: faaaca068c010e91f52dbac2f5473013515d7bd59612ea690cfd3ef14d752575

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 Bytes

Contents

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

    def self.clear_generated_description
      self.last_matcher = nil
      self.last_expectation_handler = nil
    end

    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

1 entries across 1 versions & 1 rubygems

Version Path
rspec-expectations-3.0.0.beta2 lib/rspec/matchers/generated_descriptions.rb