Class: RSpec::SleepingKingStudios::Support::MethodSignatureExpectation Private
- Inherits:
-
Object
- Object
- RSpec::SleepingKingStudios::Support::MethodSignatureExpectation
- Defined in:
- lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb
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.
Instance Attribute Summary collapse
- #any_keywords ⇒ Object writeonly private
- #block_argument ⇒ Object writeonly private
- #errors ⇒ Object readonly private
- #keywords ⇒ Object private
- #max_arguments ⇒ Object private
- #min_arguments ⇒ Object private
- #unlimited_arguments ⇒ Object writeonly private
Instance Method Summary collapse
- #any_keywords? ⇒ Boolean private
- #block_argument? ⇒ Boolean private
-
#description ⇒ Object
private
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity.
-
#initialize ⇒ MethodSignatureExpectation
constructor
private
rubocop:disable Metrics/ClassLength.
- #matches?(method) ⇒ Boolean private
- #unlimited_arguments? ⇒ Boolean private
Constructor Details
#initialize ⇒ MethodSignatureExpectation
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.
rubocop:disable Metrics/ClassLength
10 11 12 13 14 15 16 17 18 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 10 def initialize @min_arguments = 0 @max_arguments = 0 @unlimited_arguments = false @keywords = [] @any_keywords = false @block_argument = false @errors = {} end |
Instance Attribute Details
#any_keywords=(value) ⇒ Object (writeonly)
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.
22 23 24 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 22 def any_keywords=(value) @any_keywords = value end |
#block_argument=(value) ⇒ Object (writeonly)
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.
22 23 24 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 22 def block_argument=(value) @block_argument = value end |
#errors ⇒ Object (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.
24 25 26 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 24 def errors @errors end |
#keywords ⇒ Object
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.
20 21 22 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 20 def keywords @keywords end |
#max_arguments ⇒ Object
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.
20 21 22 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 20 def max_arguments @max_arguments end |
#min_arguments ⇒ Object
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.
20 21 22 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 20 def min_arguments @min_arguments end |
#unlimited_arguments=(value) ⇒ Object (writeonly)
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.
22 23 24 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 22 def unlimited_arguments=(value) @unlimited_arguments = value end |
Instance Method Details
#any_keywords? ⇒ 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.
61 62 63 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 61 def any_keywords? !!@any_keywords end |
#block_argument? ⇒ 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.
65 66 67 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 65 def block_argument? !!@block_argument end |
#description ⇒ Object
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.
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 26 def description # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity = [] << if min_arguments == max_arguments "#{min_arguments} argument#{'s' unless min_arguments == 1}" else "#{min_arguments}..#{max_arguments} arguments" end << 'unlimited arguments' if unlimited_arguments? unless keywords.empty? keywords_list = array_tools.humanize_list keywords.map(&:inspect) << "keyword#{'s' unless keywords.one?} #{keywords_list}" end << 'arbitrary keywords' if any_keywords? << 'a block' if block_argument? "with #{array_tools.humanize_list }" end |
#matches?(method) ⇒ 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.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 50 def matches?(method) @signature = MethodSignature.new(method) @errors = {} match = true match = false unless matches_arity? match = false unless matches_keywords? match = false unless matches_block? match end |
#unlimited_arguments? ⇒ 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.
69 70 71 |
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 69 def unlimited_arguments? !!@unlimited_arguments end |