Class: Sus::Have::Value
- Inherits:
-
Object
- Object
- Sus::Have::Value
- Defined in:
- lib/sus/have.rb
Instance Method Summary collapse
- #call(assertions, subject) ⇒ Object
-
#initialize(predicate) ⇒ Value
constructor
A new instance of Value.
- #print(output) ⇒ Object
Constructor Details
#initialize(predicate) ⇒ Value
Returns a new instance of Value.
53 54 55 |
# File 'lib/sus/have.rb', line 53 def initialize(predicate) @predicate = predicate end |
Instance Method Details
#call(assertions, subject) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/sus/have.rb', line 61 def call(assertions, subject) index = 0 subject.each do |value| assertions.nested("[#{index}] = #{value.inspect}", distinct: true) do |assertions| @predicate&.call(assertions, value) end index += 1 end end |
#print(output) ⇒ Object
57 58 59 |
# File 'lib/sus/have.rb', line 57 def print(output) output.write("value ", @predicate, :reset) end |