Sha256: aefdc9feb2bbc0e507a574815a9fc675e4512c6adac1010369b5a212fe6cc39b

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module RSpec
    module PrimitiveMatchers
      module Classes
        class HaveAbstractMethod
          def initialize(method_name)
            @method_name = method_name
          end

          def matches?(object)
            @object = object

            begin
              object.__send__(method_name)

              false
            rescue ConvenientService::Support::AbstractMethod::Exceptions::AbstractMethodNotOverridden
              true
            rescue
              false
            end
          end

          def description
            "have abstract method `#{method_name}`"
          end

          def failure_message
            "expected `#{object.class}` to have abstract method `#{method_name}`"
          end

          def failure_message_when_negated
            "expected `#{object.class}` NOT to have abstract method `#{method_name}`"
          end

          private

          attr_reader :object, :method_name
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
convenient_service-0.19.1 lib/convenient_service/rspec/primitive_matchers/classes/have_abstract_method.rb
convenient_service-0.19.0 lib/convenient_service/rspec/primitive_matchers/classes/have_abstract_method.rb
convenient_service-0.18.0 lib/convenient_service/rspec/primitive_matchers/classes/have_abstract_method.rb
convenient_service-0.17.0 lib/convenient_service/rspec/primitive_matchers/classes/have_abstract_method.rb
convenient_service-0.16.0 lib/convenient_service/rspec/primitive_matchers/classes/have_abstract_method.rb
convenient_service-0.15.0 lib/convenient_service/rspec/primitive_matchers/classes/have_abstract_method.rb