Class: Sus::Have::Attribute

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

Instance Method Summary collapse

Constructor Details

#initialize(name, predicate) ⇒ Attribute

Returns a new instance of Attribute.



32
33
34
35
# File 'lib/sus/have.rb', line 32

def initialize(name, predicate)
	@name = name
	@predicate = predicate
end

Instance Method Details

#call(assertions, subject) ⇒ Object



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

def call(assertions, subject)
	assertions.nested(self) do |assertions|
		assertions.assert(subject.respond_to?(@name), "has attribute")
		if @predicate
			Expect.new(assertions, subject.send(@name)).to(@predicate)
		end
	end
end


37
38
39
# File 'lib/sus/have.rb', line 37

def print(output)
	output.write("attribute ", :variable, @name.to_s, :reset, " ", @predicate, :reset)
end