Class: RSpec::SleepingKingStudios::Support::MethodSignatureExpectation Private

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeMethodSignatureExpectation

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 MethodSignatureExpectation.



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

#errorsObject (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

#keywordsObject

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.

method initialize



20
21
22
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 20

def keywords
  @keywords
end

#max_argumentsObject

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.

method initialize



20
21
22
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 20

def max_arguments
  @max_arguments
end

#min_argumentsObject

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.

method initialize



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.

method matches?

Returns:

  • (Boolean)


60
61
62
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 60

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.

method any_keywords?

Returns:

  • (Boolean)


64
65
66
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 64

def block_argument?
  !!@block_argument
end

#descriptionObject

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.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 26

def description
  messages = []

  if min_arguments == max_arguments
    messages << "#{min_arguments} argument#{1 == min_arguments ? '' : 's'}"
  else
    messages << "#{min_arguments}..#{max_arguments} arguments"
  end # if-else

  messages << 'unlimited arguments' if unlimited_arguments?

  unless keywords.empty?
    keywords_list = array_tools.humanize_list keywords.map(&:inspect)
    messages << "keyword#{1 == keywords.count ? '' : 's'} #{keywords_list}"
  end # if

  messages << 'arbitrary keywords' if any_keywords?

  messages << 'a block' if block_argument?

  "with #{array_tools.humanize_list messages}"
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.

method description

Returns:

  • (Boolean)


49
50
51
52
53
54
55
56
57
58
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 49

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.

method block_argument?

Returns:

  • (Boolean)


68
69
70
# File 'lib/rspec/sleeping_king_studios/support/method_signature_expectation.rb', line 68

def unlimited_arguments?
  !!@unlimited_arguments
end