Sha256: 1f46b0613eb7e8c7ce174787ff2e7c3291f08a9a2b48d4504625a75784c597fd

Contents?: true

Size: 1.19 KB

Versions: 15

Compression:

Stored size: 1.19 KB

Contents

# -*- coding: utf-8 -*-
require 'tengine/rspec'

# Kernelのcontextをラップするクラスです
class Tengine::RSpec::ContextWrapper
  attr_accessor :__driver__

  def initialize(kernel)
    @kernel = kernel
    @context = @kernel.context
  end

  def receive(event_type_name, options = {})
    mock_headers = Object.new
    mock_headers.should_receive(:ack)
    raw_event = Tengine::Event.new({:event_type_name => event_type_name}.update(options || {}))
    @kernel.process_message(mock_headers, raw_event.to_json)
  end

  def should_receive(*args)
    @context.should_receive(*args)
  end

  def should_not_receive(*args)
    @context.should_not_receive(*args)
  end

  def should_fire(*args)
    @kernel.should_receive(:fire).with(*args)
  end
  def should_not_fire(*args)
    if args.empty?
      @kernel.should_not_receive(:fire)
    else
      @kernel.should_not_receive(:fire).with(*args)
    end
  end

  def __driver_class__
    @__driver_class__ ||= __driver__.target_class_name.constantize
  end

  def __driver_object__
    unless @__driver_object__
      @__driver_object__ = __driver_class__.new
      __driver_class__.stub(:new).and_return(@__driver_object__)
    end
    @__driver_object__
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
tengine_core-1.2.2 lib/tengine/rspec/context_wrapper.rb
tengine_core-1.2.1 lib/tengine/rspec/context_wrapper.rb
tengine_core-1.2.0 lib/tengine/rspec/context_wrapper.rb
tengine_core-1.1.0 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.39 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.38 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.37 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.36 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.35 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.34 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.33 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.32 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.31 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.30 lib/tengine/rspec/context_wrapper.rb
tengine_core-0.5.28 lib/tengine/rspec/context_wrapper.rb