Sha256: a177bfec8ab1cbdfb44b66612b10dc324f50a116aea4e5cb8de87f755a82d989

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 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} #{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 #describe 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

11 entries across 11 versions & 2 rubygems

Version Path
dchelimsky-rspec-1.1.11.1 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.11.2 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.11.3 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.11.4 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.11.5 lib/spec/matchers/generated_descriptions.rb
dchelimsky-rspec-1.1.11.6 lib/spec/matchers/generated_descriptions.rb
spree-0.6.0 vendor/plugins/rspec/lib/spec/matchers/generated_descriptions.rb
spree-0.7.1 vendor/plugins/rspec/lib/spec/matchers/generated_descriptions.rb
spree-0.7.0 vendor/plugins/rspec/lib/spec/matchers/generated_descriptions.rb
spree-0.8.0 vendor/plugins/rspec/lib/spec/matchers/generated_descriptions.rb
spree-0.8.1 vendor/plugins/rspec/lib/spec/matchers/generated_descriptions.rb