Sha256: 1d91d39c40cb05f5038f8814d81862b6ea3df041507a1ac9a3550cfb06849267

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

module Spec
  module Matchers
    def self.last_matcher
      @last_matcher
    end

    def self.last_matcher=(last_matcher)
      @last_matcher = last_matcher
    end

    def self.last_should
      @last_should
    end

    def self.last_should=(last_should)
      @last_should = 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 }

the runner 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

17 entries across 17 versions & 2 rubygems

Version Path
dchelimsky-rspec-1.1.99.1 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.99.13 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.99.2 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.99.3 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.99.4 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.99.5 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.99.6 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.99.7 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.99.8 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.99.9 lib/spec/matchers/generated_descriptions.rb
rspec-1.2.2 lib/spec/matchers/generated_descriptions.rb
rspec-1.2.1 lib/spec/matchers/generated_descriptions.rb
rspec-1.2.0 lib/spec/matchers/generated_descriptions.rb
rspec-1.2.6 lib/spec/matchers/generated_descriptions.rb
rspec-1.2.3 lib/spec/matchers/generated_descriptions.rb
rspec-1.2.5 lib/spec/matchers/generated_descriptions.rb
rspec-1.2.4 lib/spec/matchers/generated_descriptions.rb