Sha256: e26b2243836d74fe0658af26761508a29d2d54c792c4d958ecd99301131c8fc0

Contents?: true

Size: 926 Bytes

Versions: 10

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

module Boppers
  module Testing
    class NotifierLinter
      extend Minitest::Assertions

      class << self
        attr_accessor :assertions
      end

      @assertions = 0

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

      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

      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
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
boppers-0.0.10 lib/boppers/testing/notifier_linter.rb
boppers-0.0.9 lib/boppers/testing/notifier_linter.rb
boppers-0.0.8 lib/boppers/testing/notifier_linter.rb
boppers-0.0.7 lib/boppers/testing/notifier_linter.rb
boppers-0.0.6 lib/boppers/testing/notifier_linter.rb
boppers-0.0.5 lib/boppers/testing/notifier_linter.rb
boppers-0.0.4 lib/boppers/testing/notifier_linter.rb
boppers-0.0.3 lib/boppers/testing/notifier_linter.rb
boppers-0.0.2 lib/boppers/testing/notifier_linter.rb
boppers-0.0.1 lib/boppers/testing/notifier_linter.rb