Sha256: 2613449f177b1605980ce97fbffe1eb8534b6ae3b2ccf128ddc9400640384097

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

class Sinclair
  module Matchers
    # @api private
    # @author darthjee
    #
    # AddClassMethod is able to build an instance of {Sinclair::Matchers::AddClassMethodTo}
    class AddClassMethod < AddMethod
      # @example Checking if a class had a class method added
      #   RSpec.configure do |config|
      #     config.include Sinclair::Matchers
      #   end
      #
      #   class MyModel
      #   end
      #
      #   RSpec.describe 'MyBuilder' do
      #     let(:clazz)   { Class.new(MyModel) }
      #
      #     let(:block) do
      #       proc do
      #         clazz.define_singleton_method(:new_method) { 2 }
      #       end
      #     end
      #
      #     it do
      #       expect(&block).to add_class_method(:new_method).to(clazz)
      #     end
      #   end
      #
      #   # outputs
      #   # should add method class_method 'new_method' to #<Class:0x000055b4d0a25c80>
      with_final_matcher :to, AddClassMethodTo

      private

      # @private
      #
      # Error description on wrong usage
      #
      # @return String
      def matcher_error
        'You should specify which class the method is being added to' \
          "add_class_method(:#{method_name}).to(klass)"
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sinclair-2.1.1 lib/sinclair/matchers/add_class_method.rb
sinclair-2.1.0 lib/sinclair/matchers/add_class_method.rb
sinclair-2.0.1 lib/sinclair/matchers/add_class_method.rb
sinclair-2.0.0 lib/sinclair/matchers/add_class_method.rb
sinclair-1.16.3 lib/sinclair/matchers/add_class_method.rb
sinclair-1.16.2 lib/sinclair/matchers/add_class_method.rb
sinclair-1.16.1 lib/sinclair/matchers/add_class_method.rb
sinclair-1.16.0 lib/sinclair/matchers/add_class_method.rb
sinclair-1.15.0 lib/sinclair/matchers/add_class_method.rb
sinclair-1.14.2 lib/sinclair/matchers/add_class_method.rb
sinclair-1.14.1 lib/sinclair/matchers/add_class_method.rb
sinclair-1.14.0 lib/sinclair/matchers/add_class_method.rb
sinclair-1.13.0 lib/sinclair/matchers/add_class_method.rb
sinclair-1.12.1 lib/sinclair/matchers/add_class_method.rb
sinclair-1.12.0 lib/sinclair/matchers/add_class_method.rb
sinclair-1.11.0 lib/sinclair/matchers/add_class_method.rb