Class: Sus::RespondTo::WithParameters
- Inherits:
-
Object
- Object
- Sus::RespondTo::WithParameters
- Defined in:
- lib/sus/respond_to.rb
Instance Method Summary collapse
- #call(assertions, subject) ⇒ Object
-
#initialize(parameters) ⇒ WithParameters
constructor
A new instance of WithParameters.
Constructor Details
#initialize(parameters) ⇒ WithParameters
Returns a new instance of WithParameters.
10 11 12 |
# File 'lib/sus/respond_to.rb', line 10 def initialize(parameters) @parameters = parameters end |
Instance Method Details
#call(assertions, subject) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sus/respond_to.rb', line 14 def call(assertions, subject) parameters = @parameters.dup assertions.nested(self) do |assertions| expected_name = parameters.shift subject.each do |type, name| case type when :req assertions.assert(name == expected_name, "parameter #{expected_name} is required, but was #{name}") when :opt break if expected_name.nil? assertions.assert(name == expected_name, "parameter #{expected_name} is specified, but was #{name}") else break end end end end |