Class: Expected::Matchers::ExtendModuleMatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/expected/matchers/extend_module.rb

Overview

Class used by #extend_module

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expected_module) ⇒ ExtendModuleMatcher

Returns a new instance of ExtendModuleMatcher.

Parameters:

  • expected_module (Class)

    The module the #subject is expected to include



23
24
25
# File 'lib/expected/matchers/extend_module.rb', line 23

def initialize(expected_module)
  @expected_module = expected_module
end

Instance Attribute Details

#expected_moduleObject (readonly)

Returns the value of attribute expected_module.



20
21
22
# File 'lib/expected/matchers/extend_module.rb', line 20

def expected_module
  @expected_module
end

#subjectObject

Returns the value of attribute subject.



20
21
22
# File 'lib/expected/matchers/extend_module.rb', line 20

def subject
  @subject
end

Instance Method Details

#descriptionString

Returns:

  • (String)


48
49
50
# File 'lib/expected/matchers/extend_module.rb', line 48

def description
  "extend_module: <#{expected_module.inspect}>"
end

#failure_messageString

Returns:

  • (String)


38
39
40
# File 'lib/expected/matchers/extend_module.rb', line 38

def failure_message
  "Expected #{expectation}"
end

#failure_message_when_negatedString

Returns:

  • (String)


43
44
45
# File 'lib/expected/matchers/extend_module.rb', line 43

def failure_message_when_negated
  "Did not expect #{expectation}"
end

#matches?(subject) ⇒ True, False

Run the test

Parameters:

  • subject

    The thing to test against

Returns:

  • (True)

    If the test passes

  • (False)

    if the test fails



31
32
33
34
35
# File 'lib/expected/matchers/extend_module.rb', line 31

def matches?(subject)
  self.subject = subject
  klass = self.subject.singleton_class
  klass.included_modules.include? expected_module
end