Class: Contracts::Expects
Instance Attribute Summary collapse
-
#expectations ⇒ Object
readonly
Returns the value of attribute expectations.
Attributes inherited from Base
Instance Method Summary collapse
- #before_call(_receiver, *args, &_blk) ⇒ Object
-
#initialize(expectations) ⇒ Expects
constructor
A new instance of Expects.
Methods inherited from Base
Constructor Details
#initialize(expectations) ⇒ Expects
Returns a new instance of Expects.
15 16 17 |
# File 'lib/contracts/expects.rb', line 15 def initialize(expectations) @expectations = expectations end |
Instance Attribute Details
#expectations ⇒ Object (readonly)
Returns the value of attribute expectations.
13 14 15 |
# File 'lib/contracts/expects.rb', line 13 def expectations @expectations end |
Instance Method Details
#before_call(_receiver, *args, &_blk) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/contracts/expects.rb', line 19 def before_call(_receiver, *args, &_blk) args.each_with_index do |value, idx| next unless expectation = expectations_ary[idx] Expectation::Matcher.match! value, expectation end nil rescue Expectation::Error error! "#{$ERROR_INFO} in call to `#{method_name}`" end |