Sha256: 38ec630d4febc28997fa441ff7f653cbb8777ca635a6f8739e7a26a82395473d

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'rubygems'
require 'parse_tree'
require 'ruby2ruby'
require 'cross-stub/stub_helpers'
require 'cross-stub/setup_helpers'
require 'cross-stub/cache_helpers'
require 'cross-stub/pseudo_class'

module CrossStub

  class Error < Exception ; end
  class CannotStubInstanceError < Error ; end

  class << self

    include CacheHelpers
    include SetupHelpers
    include StubHelpers

    attr_reader :options

    def setup(opts)
      @options = opts
      setup_for_current_process
    end

    def clear
      clear_stubs_for_current_process
    end

    def apply(*args, &blk)
      apply_stubs_for_current_process(*args, &blk)
    end

    def refresh(opts)
      @options = opts
      apply_or_unapply_stubs_for_other_process
    end

  end

  module ClassMethods
    def xstub(*args, &blk)
      CrossStub.apply(self, args, &blk)
    end
  end

  module InstanceMethods
    def xstub(*args)
      raise CannotStubInstanceError
    end
  end

end

Object.send(:extend, CrossStub::ClassMethods)
Object.send(:include, CrossStub::InstanceMethods)
Module.send(:include, CrossStub::ClassMethods)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cross-stub-0.1.4 lib/cross-stub.rb
cross-stub-0.1.3.1 lib/cross-stub.rb
cross-stub-0.1.3 lib/cross-stub.rb