Class: Bogus::WithArguments
- Inherits:
-
Object
- Object
- Bogus::WithArguments
- Defined in:
- lib/bogus/stubbing/matchers/with_arguments.rb
Instance Attribute Summary collapse
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(&predicate) ⇒ WithArguments
constructor
A new instance of WithArguments.
- #matches?(args) ⇒ Boolean
Constructor Details
#initialize(&predicate) ⇒ WithArguments
Returns a new instance of WithArguments.
5 6 7 |
# File 'lib/bogus/stubbing/matchers/with_arguments.rb', line 5 def initialize(&predicate) @predicate = predicate end |
Instance Attribute Details
#predicate ⇒ Object (readonly)
Returns the value of attribute predicate.
3 4 5 |
# File 'lib/bogus/stubbing/matchers/with_arguments.rb', line 3 def predicate @predicate end |
Class Method Details
.matches?(opts = {}) ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/bogus/stubbing/matchers/with_arguments.rb', line 13 def self.matches?(opts = {}) stubbed = opts.fetch(:stubbed) recorded = opts.fetch(:recorded) return false unless with_matcher?(stubbed) return extract(stubbed).matches?(recorded) end |
.with_matcher?(args) ⇒ Boolean
20 21 22 |
# File 'lib/bogus/stubbing/matchers/with_arguments.rb', line 20 def self.with_matcher?(args) args.first.is_a?(WithArguments) end |
Instance Method Details
#matches?(args) ⇒ Boolean
9 10 11 |
# File 'lib/bogus/stubbing/matchers/with_arguments.rb', line 9 def matches?(args) predicate.call(*args) end |