Class: RSpec::Support::MethodSignatureVerifier Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/support/method_signature_verifier.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Abstract base class for signature verifiers.

Direct Known Subclasses

LooseSignatureVerifier

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(signature, args) ⇒ MethodSignatureVerifier

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MethodSignatureVerifier.



180
181
182
183
# File 'lib/rspec/support/method_signature_verifier.rb', line 180

def initialize(signature, args)
  @signature = signature
  @non_kw_args, @kw_args = split_args(*args)
end

Instance Attribute Details

#kw_argsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



178
179
180
# File 'lib/rspec/support/method_signature_verifier.rb', line 178

def kw_args
  @kw_args
end

#non_kw_argsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



178
179
180
# File 'lib/rspec/support/method_signature_verifier.rb', line 178

def non_kw_args
  @non_kw_args
end

Instance Method Details

#error_messageObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/rspec/support/method_signature_verifier.rb', line 191

def error_message
  if missing_kw_args.any?
    "Missing required keyword arguments: %s" % [
      missing_kw_args.join(", ")
    ]
  elsif invalid_kw_args.any?
    "Invalid keyword arguments provided: %s" % [
      invalid_kw_args.join(", ")
    ]
  elsif !valid_non_kw_args?
    "Wrong number of arguments. Expected %s, got %s." % [
      @signature.non_kw_args_arity_description,
      non_kw_args.length
    ]
  end
end

#valid?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


185
186
187
188
189
# File 'lib/rspec/support/method_signature_verifier.rb', line 185

def valid?
  missing_kw_args.empty? &&
    invalid_kw_args.empty? &&
    valid_non_kw_args?
end