Sha256: aa2ab958586ddf3317e5d9817bb04917147a50df129fa45f938e5bb0658c42e9

Contents?: true

Size: 856 Bytes

Versions: 6

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module RSpec
    module PrimitiveMatchers
      module Classes
        class PrependModule
          ##
          # NOTE: `mod` since `module` is a keyword.
          #
          def initialize(mod)
            @mod = mod
          end

          def matches?(klass)
            @klass = klass

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

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

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

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

          private

          attr_reader :klass, :mod
        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/prepend_module.rb
convenient_service-0.19.0 lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb
convenient_service-0.18.0 lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb
convenient_service-0.17.0 lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb
convenient_service-0.16.0 lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb
convenient_service-0.15.0 lib/convenient_service/rspec/primitive_matchers/classes/prepend_module.rb