Sha256: 8b15a8b982850f8c5088e61583121a704376a668aa4c0a746a1f661892fece55

Contents?: true

Size: 1.64 KB

Versions: 11

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

class Sinclair
  # @api public
  # @author darthjee
  #
  # Matchers module will have the DSL to be included in RSpec in order to have
  # access to the matchers
  #
  # @example
  #  RSpec.configure do |config|
  #    config.include Sinclair::Matchers
  #  end
  #
  #  class MyModel
  #  end
  #
  #  RSpec.describe 'my test' do
  #    let(:klass)   { Class.new(MyModel) }
  #    let(:builder) { Sinclair.new(klass) }
  #
  #    before do
  #      builder.add_method(:class_name, 'self.class.name')
  #    end
  #
  #    it do
  #      expect { builder.build }.to add_method(:class_name).to(klass)
  #    end
  #  end
  module Matchers
    autoload :AddMethod,           'sinclair/matchers/add_method'
    autoload :AddInstanceMethod,   'sinclair/matchers/add_instance_method'
    autoload :AddClassMethod,      'sinclair/matchers/add_class_method'
    autoload :AddMethodTo,         'sinclair/matchers/add_method_to'
    autoload :AddInstanceMethodTo, 'sinclair/matchers/add_instance_method_to'
    autoload :AddClassMethodTo,    'sinclair/matchers/add_class_method_to'

    # DSL to AddInstanceMethod
    #
    # @example (see Sinclair::Matchers)
    # @example (see Sinclair::Matchers::AddInstanceMethod#to)
    #
    # @return [AddInstanceMethod] RSpec Matcher
    def add_method(method)
      Sinclair::Matchers::AddInstanceMethod.new(method)
    end

    # DSL to AddClassMethod
    #
    # @example (see Sinclair::Matchers)
    # @example (see Sinclair::Matchers::AddClassMethod#to)
    #
    # @return [AddClassMethod] RSpec Matcher
    def add_class_method(method)
      Sinclair::Matchers::AddClassMethod.new(method)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sinclair-1.6.6 lib/sinclair/matchers.rb
sinclair-1.6.5 lib/sinclair/matchers.rb
sinclair-1.6.4 lib/sinclair/matchers.rb
sinclair-1.6.3 lib/sinclair/matchers.rb
sinclair-1.6.2 lib/sinclair/matchers.rb
sinclair-1.6.1 lib/sinclair/matchers.rb
sinclair-1.6.0 lib/sinclair/matchers.rb
sinclair-1.5.2 lib/sinclair/matchers.rb
sinclair-1.5.1 lib/sinclair/matchers.rb
sinclair-1.5.0 lib/sinclair/matchers.rb
sinclair-1.4.2 lib/sinclair/matchers.rb