class Expected::Matchers::ExtendModuleMatcher

Class used by {#extend_module}

Attributes

expected_module[R]
subject[R]

Public Class Methods

new(expected_module) click to toggle source

@param expected_module [Class] The module the {#subject} is expected to include

# File lib/expected/matchers/extend_module.rb, line 23
def initialize(expected_module)
  @expected_module = expected_module
end

Public Instance Methods

description() click to toggle source

@return [String]

# File lib/expected/matchers/extend_module.rb, line 48
def description
  "extend_module: <#{expected_module.inspect}>"
end
failure_message() click to toggle source

@return [String]

# File lib/expected/matchers/extend_module.rb, line 38
def failure_message
  "Expected #{expectation}"
end
failure_message_when_negated() click to toggle source

@return [String]

# File lib/expected/matchers/extend_module.rb, line 43
def failure_message_when_negated
  "Did not expect #{expectation}"
end
matches?(subject) click to toggle source

Run the test @param subject The thing to test against @return [True] If the test passes @return [False] if the test fails

# 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

Private Instance Methods

expectation() click to toggle source

@return String

# File lib/expected/matchers/extend_module.rb, line 61
def expectation
  "<#{subject.inspect}> to extend <#{expected_module.inspect}>"
end
subject=(subject) click to toggle source

The thing to test against @return [Class, Module]

# File lib/expected/matchers/extend_module.rb, line 56
def subject=(subject)
  @subject = subject.instance_of?(Class) || subject.is_a?(Module) ? subject : subject.class
end