Sha256: d7c68eb6a298d985d27a92bad708a407d0e00982a142a0543080b683d9919b1a

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'spec_helper')
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'includes')

shared 'has standard setup' do
  before { CrossStub.setup(cache_store(@store_type)) }
  after { CrossStub.clear }
end

shared 'has current process setup' do
  behaves_like 'has standard setup'
  before { @call = Object.method(:do_local_method_call) }
end

shared 'has other process setup' do

  behaves_like 'has standard setup'

  before do
    @call = lambda do |method_call_args|
      do_remote_method_call("%s/%s" % [@store_type, method_call_args])
    end
    $service_started ||= (
      ENV['FORK_SERVER'] != 'false' && (
        Otaku.start do |data|
          @@_not_isolated_vars = :all # we don't wanna isolate any contextual references
          require File.join(File.dirname(__FILE__), '..', 'includes')
          store_type, method_call_args = data.match(/^(.*?)\/(.*)$/)[1..2]
          CrossStub.refresh(cache_store($prev_store_type)) if $prev_store_type
          CrossStub.refresh(cache_store($prev_store_type = store_type))
          do_local_method_call(method_call_args) rescue $!.message
        end
      ) ; true
    )
  end

end

at_exit do
  ENV['FORK_SERVER'] != 'false' && $service_started && Otaku.stop
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cross-stub-0.2.4 spec/integration/shared_spec.rb
cross-stub-0.2.3 spec/integration/shared_spec.rb