Class: Boppers::Testing::NotifierLinter

Inherits:
Object
  • Object
show all
Extended by:
Minitest::Assertions
Defined in:
lib/boppers/testing/notifier_linter.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.assertionsObject

Returns the value of attribute assertions.



9
10
11
# File 'lib/boppers/testing/notifier_linter.rb', line 9

def assertions
  @assertions
end

Class Method Details

.assert_call_method(notifier) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/boppers/testing/notifier_linter.rb', line 27

def self.assert_call_method(notifier)
  message =
    "Notifier must implement #{notifier.class}#call" \
    "(title, message, options)"
  call_method = notifier.method(:call)
  assert_equal 3, call_method.parameters.size, message
end

.assert_initialize_method(notifier) ⇒ Object



20
21
22
23
24
25
# File 'lib/boppers/testing/notifier_linter.rb', line 20

def self.assert_initialize_method(notifier)
  message =
    "Notifier must implement #{notifier.class}.new(subscribe: nil)"
  initialize_method = notifier.method(:initialize)
  assert_includes initialize_method.parameters, %i[key subscribe], message
end

.call(notifier) ⇒ Object



14
15
16
17
18
# File 'lib/boppers/testing/notifier_linter.rb', line 14

def self.call(notifier)
  assert_respond_to(notifier, :call)
  assert_initialize_method(notifier)
  assert_call_method(notifier)
end