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.
52 53 54 |
# File 'lib/sus/have.rb', line 52 def initialize(predicate) @predicate = predicate end |
Instance Method Details
#call(assertions, subject) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/sus/have.rb', line 60 def call(assertions, subject) subject.each_with_index do |value, index| assertions.nested("[#{index}] = #{value.inspect}") do |assertions| @predicate&.call(assertions, value) end end end |
#print(output) ⇒ Object
56 57 58 |
# File 'lib/sus/have.rb', line 56 def print(output) output.write("value ", @predicate, :reset) end |