Class: CulpaHelpers::BrickCall
- Inherits:
-
Object
- Object
- CulpaHelpers::BrickCall
- Defined in:
- lib/culpa/test_helpers.rb
Overview
Class used to mock a brick call
Instance Attribute Summary collapse
-
#from_done ⇒ Object
readonly
Returns the value of attribute from_done.
Instance Method Summary collapse
- #call ⇒ Object
- #from(action_const) ⇒ Object
-
#initialize(brick_name) ⇒ BrickCall
constructor
A new instance of BrickCall.
- #with(opts) ⇒ Object
Constructor Details
#initialize(brick_name) ⇒ BrickCall
Returns a new instance of BrickCall.
23 24 25 26 |
# File 'lib/culpa/test_helpers.rb', line 23 def initialize(brick_name) @brick_name = brick_name.to_s @from_done = false end |
Instance Attribute Details
#from_done ⇒ Object (readonly)
Returns the value of attribute from_done.
21 22 23 |
# File 'lib/culpa/test_helpers.rb', line 21 def from_done @from_done end |
Instance Method Details
#call ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/culpa/test_helpers.rb', line 42 def call return unless @from_done return @call_cache if @call_done @envelope ||= Culpa::Envelope.new({}) @params ||= Culpa::EnvelopeRequest.new({}) @action_const.new(@envelope, @params).send(@brick_name) @call_done = true return @call_cache = { to_render: nil, envelope: @envelope } rescue Action::RenderNow => renderer return @call_cache = { to_render: renderer.to_render, envelope: @envelope } end |
#from(action_const) ⇒ Object
28 29 30 31 32 |
# File 'lib/culpa/test_helpers.rb', line 28 def from(action_const) @from_done = true @action_const = action_const self end |