Class: Sus::Have::All

Inherits:
Object
  • Object
show all
Defined in:
lib/sus/have/all.rb

Overview

Represents a predicate that checks if the subject matches all of the given predicates.

Instance Method Summary collapse

Constructor Details

#initialize(predicates) ⇒ All

Initialize a new All predicate.



12
13
14
# File 'lib/sus/have/all.rb', line 12

def initialize(predicates)
	@predicates = predicates
end

Instance Method Details

#call(assertions, subject) ⇒ Object

Evaluate this predicate against a subject.



36
37
38
39
40
41
42
# File 'lib/sus/have/all.rb', line 36

def call(assertions, subject)
	assertions.nested(self) do |assertions|
		@predicates.each do |predicate|
			predicate.call(assertions, subject)
		end
	end
end

Print a representation of this predicate.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sus/have/all.rb', line 18

def print(output)
	first = true
	output.write("have {")
	@predicates.each do |predicate|
		if first
			first = false
		else
			output.write(", ")
		end
		
		output.write(predicate)
	end
	output.write("}")
end