Module: FlexMock::ArgumentMatching
- Defined in:
- lib/flexmock/argument_matching.rb
Constant Summary collapse
- MISSING_ARG =
Object.new
Class Method Summary collapse
- .all_match?(expected_args, actual_args) ⇒ Boolean
-
.match?(expected, actual) ⇒ Boolean
Does the expected argument match the corresponding actual value.
- .missing?(arg) ⇒ Boolean
Class Method Details
.all_match?(expected_args, actual_args) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/flexmock/argument_matching.rb', line 7 def all_match?(expected_args, actual_args) return true if expected_args.nil? return false if actual_args.size > expected_args.size i = 0 while i < actual_args.size return false unless match?(expected_args[i], actual_args[i]) i += 1 end while i < expected_args.size return false unless match?(expected_args[i], MISSING_ARG) i += 1 end true end |
.match?(expected, actual) ⇒ Boolean
Does the expected argument match the corresponding actual value.
23 24 25 26 27 |
# File 'lib/flexmock/argument_matching.rb', line 23 def match?(expected, actual) expected === actual || expected == actual || ( Regexp === expected && expected === actual.to_s ) end |
.missing?(arg) ⇒ Boolean
29 30 31 |
# File 'lib/flexmock/argument_matching.rb', line 29 def missing?(arg) arg == MISSING_ARG end |