Sha256: 1b40217b13457f100897de84b898706e10e3117cc87db08538999a43c07278be

Contents?: true

Size: 871 Bytes

Versions: 55

Compression:

Stored size: 871 Bytes

Contents

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

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

    def self.generated_description
      return nil if last_should.nil?
      "#{last_should.to_s.gsub('_',' ')} #{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 { object.should matcher }

or this:

it { should 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

55 entries across 55 versions & 16 rubygems

Version Path
rspec-expectations-2.14.1 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.14.0 lib/rspec/matchers/generated_descriptions.rb
sshp-0.0.2 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/generated_descriptions.rb
sshp-0.0.1 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.14.0.rc1 lib/rspec/matchers/generated_descriptions.rb
sidekiq-statsd-0.1.1 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/generated_descriptions.rb
sidekiq-statsd-0.1.0 vendor/ruby/1.9.1/gems/rspec-expectations-2.13.0/lib/rspec/matchers/generated_descriptions.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/rspec-expectations-2.12.1/lib/rspec/matchers/generated_descriptions.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/rspec-expectations-2.13.0/lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.13.0 lib/rspec/matchers/generated_descriptions.rb
remq-0.0.4 vendor/bundle/gems/rspec-expectations-2.12.1/lib/rspec/matchers/generated_descriptions.rb
remq-0.0.3 vendor/bundle/gems/rspec-expectations-2.12.1/lib/rspec/matchers/generated_descriptions.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/rspec-expectations-2.12.1/lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.12.1 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.12.0 lib/rspec/matchers/generated_descriptions.rb