Class: ConvenientService::RSpec::PrimitiveMatchers::Classes::PrependModule

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb

Instance Method Summary collapse

Constructor Details

#initialize(mod) ⇒ PrependModule

NOTE: ‘mod` since `module` is a keyword.



11
12
13
# File 'lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb', line 11

def initialize(mod)
  @mod = mod
end

Instance Method Details

#descriptionObject



21
22
23
# File 'lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb', line 21

def description
  "prepend module `#{mod}`"
end

#failure_messageObject



25
26
27
# File 'lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb', line 25

def failure_message
  "expected `#{klass}` to prepend module `#{mod}`"
end

#failure_message_when_negatedObject



29
30
31
# File 'lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb', line 29

def failure_message_when_negated
  "expected `#{klass}` NOT to prepend module `#{mod}`"
end

#matches?(klass) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb', line 15

def matches?(klass)
  @klass = klass

  klass.ancestors.take_while { |ancestor| ancestor != klass }.include?(mod)
end