Sha256: c591ffc912aef387cb061f229705df5f8a50ff51aee969817516574155adb4ee

Contents?: true

Size: 421 Bytes

Versions: 2

Compression:

Stored size: 421 Bytes

Contents

module Specs
  def self.stub_out_class_method(mod, meth)
    meta = (class << mod; self; end)
    original_meth = "original_#{meth}".to_sym

    raise "ALREADY TRACED: #{mod}.#{meth}" if mod.respond_to?(original_meth)

    meta.send(:alias_method, original_meth, meth)
    meta.send(:define_method, meth) do |*args, &block|
      yield(*args) if block_given?
      mod.send original_meth, *args, &block
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
celluloid-0.18.0 spec/support/stubbing.rb
celluloid-0.18.0.pre2 spec/support/stubbing.rb