Class: Tengine::RSpec::ContextWrapper
- Inherits:
-
Object
- Object
- Tengine::RSpec::ContextWrapper
- Defined in:
- lib/tengine/rspec/context_wrapper.rb
Overview
Kernelのcontextをラップするクラスです
Instance Attribute Summary collapse
-
#__driver__ ⇒ Object
Returns the value of attribute __driver__.
Instance Method Summary collapse
- #__driver_class__ ⇒ Object
- #__driver_object__ ⇒ Object
-
#initialize(kernel) ⇒ ContextWrapper
constructor
A new instance of ContextWrapper.
- #receive(event_type_name, options = {}) ⇒ Object
- #should_fire(*args) ⇒ Object
- #should_not_fire(*args) ⇒ Object
- #should_not_receive(*args) ⇒ Object
- #should_receive(*args) ⇒ Object
Constructor Details
#initialize(kernel) ⇒ ContextWrapper
Returns a new instance of ContextWrapper.
8 9 10 11 |
# File 'lib/tengine/rspec/context_wrapper.rb', line 8 def initialize(kernel) @kernel = kernel @context = @kernel.context end |
Instance Attribute Details
#__driver__ ⇒ Object
Returns the value of attribute __driver__.
6 7 8 |
# File 'lib/tengine/rspec/context_wrapper.rb', line 6 def __driver__ @__driver__ end |
Instance Method Details
#__driver_class__ ⇒ Object
39 40 41 |
# File 'lib/tengine/rspec/context_wrapper.rb', line 39 def __driver_class__ @__driver_class__ ||= __driver__.target_class_name.constantize end |
#__driver_object__ ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/tengine/rspec/context_wrapper.rb', line 43 def __driver_object__ unless @__driver_object__ @__driver_object__ = __driver_class__.new __driver_class__.stub(:new).and_return(@__driver_object__) end @__driver_object__ end |
#receive(event_type_name, options = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/tengine/rspec/context_wrapper.rb', line 13 def receive(event_type_name, = {}) mock_headers = Object.new mock_headers.should_receive(:ack) raw_event = Tengine::Event.new({:event_type_name => event_type_name}.update( || {})) @kernel.(mock_headers, raw_event.to_json) end |
#should_fire(*args) ⇒ Object
28 29 30 |
# File 'lib/tengine/rspec/context_wrapper.rb', line 28 def should_fire(*args) @kernel.should_receive(:fire).with(*args) end |
#should_not_fire(*args) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/tengine/rspec/context_wrapper.rb', line 31 def should_not_fire(*args) if args.empty? @kernel.should_not_receive(:fire) else @kernel.should_not_receive(:fire).with(*args) end end |
#should_not_receive(*args) ⇒ Object
24 25 26 |
# File 'lib/tengine/rspec/context_wrapper.rb', line 24 def should_not_receive(*args) @context.should_not_receive(*args) end |
#should_receive(*args) ⇒ Object
20 21 22 |
# File 'lib/tengine/rspec/context_wrapper.rb', line 20 def should_receive(*args) @context.should_receive(*args) end |