Class: MotionSpec::Matcher::RespondTo
- Defined in:
- lib/motion-spec/matcher/respond_to.rb
Instance Method Summary collapse
- #arguments ⇒ Object (also: #argument)
- #fail!(subject, negated) ⇒ Object
-
#initialize(method_name) ⇒ RespondTo
constructor
A new instance of RespondTo.
- #matches?(subject) ⇒ Boolean
- #with(number_of_args) ⇒ Object
Constructor Details
#initialize(method_name) ⇒ RespondTo
Returns a new instance of RespondTo.
5 6 7 |
# File 'lib/motion-spec/matcher/respond_to.rb', line 5 def initialize(method_name) @method_name = method_name end |
Instance Method Details
#arguments ⇒ Object Also known as: argument
14 15 16 |
# File 'lib/motion-spec/matcher/respond_to.rb', line 14 def arguments self end |
#fail!(subject, negated) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/motion-spec/matcher/respond_to.rb', line 31 def fail!(subject, negated) raise FailedExpectation.new( FailMessageRenderer.( negated, subject, @method_name, @number_of_args ) ) end |
#matches?(subject) ⇒ Boolean
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/motion-spec/matcher/respond_to.rb', line 19 def matches?(subject) valid = true valid &&= subject.respond_to?(@method_name) if valid && @number_of_args valid &&= subject.method(@method_name).arity == @number_of_args end valid end |
#with(number_of_args) ⇒ Object
9 10 11 12 |
# File 'lib/motion-spec/matcher/respond_to.rb', line 9 def with(number_of_args) @number_of_args = number_of_args self end |