Class: KeywordParameterMatchers::HaveKeywordParameter

Inherits:
Object
  • Object
show all
Defined in:
lib/keyword_parameter_matchers/have_keyword_parameter.rb

Instance Method Summary collapse

Constructor Details

#initialize(expected) ⇒ HaveKeywordParameter

Returns a new instance of HaveKeywordParameter.



3
4
5
# File 'lib/keyword_parameter_matchers/have_keyword_parameter.rb', line 3

def initialize(expected)
  @expected = expected
end

Instance Method Details

#failure_messageObject



15
16
17
18
# File 'lib/keyword_parameter_matchers/have_keyword_parameter.rb', line 15

def failure_message
  "expected \"#{expected}\" to a keyword parameter in #{method_name} " \
    "parameter list #{parameter_list.inspect}"
end

#failure_message_when_negatedObject



20
21
22
23
# File 'lib/keyword_parameter_matchers/have_keyword_parameter.rb', line 20

def failure_message_when_negated
  "expected \"#{expected}\" not to a keyword parameter in #{method_name} " \
    "parameter list #{parameter_list.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
# File 'lib/keyword_parameter_matchers/have_keyword_parameter.rb', line 7

def matches?(actual)
  @actual = actual

  actual.parameters.any? { |type, name|
    [:key, :keyreq].include?(type) && name == @expected
  }
end