Module: EventMachine::UCEngine::Brick::Test

Defined in:
lib/em-ucengine/brick_test.rb

Overview

A simple class to allowing you to test your bricks

Instance Method Summary collapse

Instance Method Details

#brickObject

Return the instance of the brick



7
8
9
10
11
12
# File 'lib/em-ucengine/brick_test.rb', line 7

def brick
  return @b unless @b.nil?
  @b = app.new
  @b.start MiniTest::Mock.new
  @b
end

#trigger(name, data = {}) ⇒ Object

Trigger a U.C.Engine event into the brick

Parameters:

  • name (String)
  • data (Hash) (defaults to: {})


18
19
20
21
22
23
# File 'lib/em-ucengine/brick_test.rb', line 18

def trigger(name, data={})
  event = data.merge "type" => name
  brick.routes[name].each do |proc|
    brick.instance_exec(event, &proc)
  end unless brick.routes[name].nil?
end