Sha256: 344fb0563e436be473539488e7ca78b7be2c384097fbc64a1bbf029176698a30

Contents?: true

Size: 1.36 KB

Versions: 11

Compression:

Stored size: 1.36 KB

Contents

# -*- coding: utf-8 -*-
require 'spec_helper'

describe "uc72_setup_eventmachine_spec" do
  before do
    Tengine::Core::Driver.delete_all
    Tengine::Core::Session.delete_all
    @dsl_path = File.expand_path('../../../../examples/uc72_setup_eventmachine.rb', File.dirname(__FILE__))
    config = Tengine::Core::Config::Core.new({
        :tengined => {
          :load_path => @dsl_path,
        },
      })
    @kernel = Tengine::Core::Kernel.new(config)
    @bootstrap = Tengine::Core::Bootstrap.new(config)
    @bootstrap.kernel = @kernel
  end

  it "EM.run実行時にsetup_eventmachineに渡されたブロックが実行されます" do
    @kernel.em_setup_blocks.length.should == 0
    expect{
      @bootstrap.load_dsl
    }.to change(@kernel.em_setup_blocks, :length).by(1)
    @kernel.em_setup_blocks.length.should == 1
    expect{
      @kernel.bind
    }.to_not change(@kernel.em_setup_blocks, :length)
    @kernel.em_setup_blocks.length.should == 1
    EM.should_receive(:run).and_yield
    EM.stub(:defer) # #enable_heartbeat
    mq = mock(:mq, :queue => nil)
    @kernel.stub(:mq).at_least(1).times.and_return(mq)
    @kernel.should_receive(:setup_mq_connection)
    @kernel.should_receive(:subscribe_queue).and_yield
    @kernel.context.should_receive(:puts).with("setup_eventmachine")
    EM.should_receive(:add_periodic_timer).with(3)
    @kernel.activate
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
tengine_core-0.5.39 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.38 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.37 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.36 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.35 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.34 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.33 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.32 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.31 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.30 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb
tengine_core-0.5.28 spec/tengine/core/dsls/uc72_setup_eventmachine_spec.rb