Class: Sus::Have::Attribute
- Inherits:
-
Object
- Object
- Sus::Have::Attribute
- Defined in:
- lib/sus/have.rb
Instance Method Summary collapse
- #call(assertions, subject) ⇒ Object
-
#initialize(name, predicate) ⇒ Attribute
constructor
A new instance of Attribute.
- #print(output) ⇒ Object
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 |
#print(output) ⇒ Object
37 38 39 |
# File 'lib/sus/have.rb', line 37 def print(output) output.write("attribute ", :variable, @name.to_s, :reset, " ", @predicate, :reset) end |