Module: Sus::Describe

Extended by:
Context
Defined in:
lib/sus/describe.rb

Overview

Represents a test group that describes a subject (class, module, or feature).

Instance Attribute Summary collapse

Attributes included from Context

#The description of this context., #children, #description, #identity

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Context

The child contexts and tests.=, The identity of this context.=, add, after, around, before, call, describe, each, empty?, extended, file, full_name, include_context, inspect, it, it_behaves_like, leaf?, let, set_temporary_name, to_s, with

Instance Attribute Details

#subjectObject

Returns the value of attribute subject.



14
15
16
# File 'lib/sus/describe.rb', line 14

def subject
  @subject
end

Class Method Details

.build(parent, subject, unique: true, &block) ⇒ Object

Build a new describe block class.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/sus/describe.rb', line 22

def self.build(parent, subject, unique: true, &block)
	base = Class.new(parent)
	base.singleton_class.prepend(Describe)
	base.children = Hash.new
	base.subject = subject
	base.description = subject.to_s
	base.identity = Identity.nested(parent.identity, base.description, unique: unique)
	base.set_temporary_name("#{self}[#{base.description}]")
	
	base.define_method(:subject, ->{subject})
	
	if block_given?
		base.class_exec(&block)
	end
	
	return base
end

Instance Method Details

Print a representation of this describe block.



42
43
44
45
46
47
# File 'lib/sus/describe.rb', line 42

def print(output)
	output.write(
		"describe ", :describe, self.description, :reset,
		# " ", self.identity.to_s
	)
end

#The subject being described.=(subjectbeingdescribed. = (value)) ⇒ Object



14
# File 'lib/sus/describe.rb', line 14

attr_accessor :subject