Sha256: 15b30ea9ae855c69e45239648c03f6a39b8431bb31e47c1670638876738ba207

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 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)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cross-stub-0.1.2 lib/cross-stub.rb
cross-stub-0.1.1 lib/cross-stub.rb
cross-stub-0.1.0 lib/cross-stub.rb