Sha256: b152821c4b32b226790a66b029d12b5d30280140f58595581aeb66e2886d5a39

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 Bytes

Contents

# frozen_string_literal: true

module Assert; end
class Assert::Context; end

module Assert::Context::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(&:empty?).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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
assert-2.19.2 lib/assert/context/subject_dsl.rb
assert-2.19.1 lib/assert/context/subject_dsl.rb