Exception: Assay::ResponseFailure
- Defined in:
- lib/assay/assertions/response_failure.rb
Overview
Does an object #respond_to? a method call.
Constant Summary
Constants inherited from Assertion
Class Method Summary collapse
- .assertion_name ⇒ Object
- .assertion_name! ⇒ Object
- .operator_name ⇒ Object
-
.pass?(reciever, method) ⇒ Boolean
Check assertion.
Instance Method Summary collapse
Methods inherited from Assertion
assert, #assert, assertable_method, #assertion?, #fail?, fail?, #initialize, #negative?, #pass?, refute, #refute, #set_arguments, #set_negative, to_matcher
Constructor Details
This class inherits a constructor from Assay::Assertion
Class Method Details
.assertion_name ⇒ Object
8 9 10 |
# File 'lib/assay/assertions/response_failure.rb', line 8 def self.assertion_name :respond_to end |
.assertion_name! ⇒ Object
12 13 14 |
# File 'lib/assay/assertions/response_failure.rb', line 12 def self.assertion_name! :not_respond_to end |
.operator_name ⇒ Object
16 17 18 |
# File 'lib/assay/assertions/response_failure.rb', line 16 def self.operator_name :respond_to? end |
.pass?(reciever, method) ⇒ Boolean
Check assertion.
21 22 23 24 25 |
# File 'lib/assay/assertions/response_failure.rb', line 21 def self.pass?(reciever, method) #flip = (Symbol === obj) && ! (Symbol === meth) # HACK for specs #obj, meth = meth, obj if flip reciever.respond_to?(method) end |
Instance Method Details
#to_s ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/assay/assertions/response_failure.rb', line 28 def to_s return @mesg if @mesg return super unless @arguments.size == 2 reciever = @arguments[0].inspect method = @arguments[1].inspect if @_negated "Expected #{reciever} (#{reciever.class}) to NOT respond to ##{method}" else "Expected #{reciever} (#{reciever.class}) to respond to ##{method}" end end |