Sha256: 965a7b34327b816b364c75dee24c18055d99d5ae39eed005737777d2f7c3d670

Contents?: true

Size: 821 Bytes

Versions: 12

Compression:

Stored size: 821 Bytes

Contents

module Assert; end
class Assert::Context

  module SubjectDSL

    # Add a piece of description text or return the full description for the context
    def description(text = nil)
      if text
        self.descriptions << text.to_s
      else
        parent = self.superclass.desc if self.superclass.respond_to?(:desc)
        own = self.descriptions
        [parent, *own].compact.reject do |p|
          p.to_s.empty?
        end.join(" ")
      end
    end
    alias_method :desc, :description
    alias_method :describe, :description

    def subject(&block)
      if block_given?
        @subject = block
      else
        @subject || if superclass.respond_to?(:subject)
          superclass.subject
        end
      end
    end

    protected

    def descriptions
      @descriptions ||= []
    end

  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
assert-2.12.2 lib/assert/context/subject_dsl.rb
assert-2.12.1 lib/assert/context/subject_dsl.rb
assert-2.12.0 lib/assert/context/subject_dsl.rb
assert-2.11.0 lib/assert/context/subject_dsl.rb
assert-2.10.1 lib/assert/context/subject_dsl.rb
assert-2.10.0 lib/assert/context/subject_dsl.rb
assert-2.9.0 lib/assert/context/subject_dsl.rb
assert-2.8.0 lib/assert/context/subject_dsl.rb
assert-2.7.1 lib/assert/context/subject_dsl.rb
assert-2.7.0 lib/assert/context/subject_dsl.rb
assert-2.6.0 lib/assert/context/subject_dsl.rb
assert-2.5.0 lib/assert/context/subject_dsl.rb