Sha256: 164c8a13da4899b12cd32ab30a20a7761ca4ee5e5b7f1cb204833dcd11a1aedb

Contents?: true

Size: 896 Bytes

Versions: 18

Compression:

Stored size: 896 Bytes

Contents

module Rspec
  module Matchers
    class << self
      attr_accessor :last_matcher, :last_should # :nodoc:
    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

18 entries across 18 versions & 1 rubygems

Version Path
rspec-expectations-2.0.0.beta.8 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.beta.7 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.beta.6 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.beta.5 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.beta.4 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.beta.3 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.beta.2 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.beta.1 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a10 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a9 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a8 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a7 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a6 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a5 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a4 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a3 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a2 lib/rspec/matchers/generated_descriptions.rb
rspec-expectations-2.0.0.a1 lib/rspec/matchers/generated_descriptions.rb