Class: Sus::RespondTo
- Inherits:
-
Object
show all
- Defined in:
- lib/sus/respond_to.rb
Defined Under Namespace
Classes: WithOptions, WithParameters
Instance Method Summary
collapse
Constructor Details
#initialize(method) ⇒ RespondTo
Returns a new instance of RespondTo.
60
61
62
63
64
|
# File 'lib/sus/respond_to.rb', line 60
def initialize(method)
@method = method
@parameters = nil
@options = nil
end
|
Instance Method Details
#call(assertions, subject) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/sus/respond_to.rb', line 75
def call(assertions, subject)
assertions.nested(self) do |assertions|
condition = subject.respond_to?(@method)
assertions.assert(condition, self)
if condition and (@parameters or @options)
parameters = subject.method(@method).parameters
@parameters.call(assertions, parameters) if @parameters
@options.call(assertions, parameters) if @options
end
end
end
|
#print(output) ⇒ Object
71
72
73
|
# File 'lib/sus/respond_to.rb', line 71
def print(output)
output.write("respond to ", :variable, @method.to_s, :reset)
end
|
#with_options(*options) ⇒ Object
66
67
68
69
|
# File 'lib/sus/respond_to.rb', line 66
def with_options(*options)
@options = WithOptions.new(options)
return self
end
|