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
- #with_session(hash) ⇒ Object
Constructor Details
Instance Attribute Details
#from_done ⇒ Object (readonly)
Returns the value of attribute from_done.
22 23 24 |
# File 'lib/culpa/test_helpers.rb', line 22 def from_done @from_done end |
Instance Method Details
#call ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/culpa/test_helpers.rb', line 48 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, @session).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
30 31 32 33 34 |
# File 'lib/culpa/test_helpers.rb', line 30 def from(action_const) @from_done = true @action_const = action_const self end |
#with(opts) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/culpa/test_helpers.rb', line 40 def with(opts) opts[:envelope] ||= {} @envelope = Culpa::Envelope.new(opts[:envelope]) opts.delete(:envelope) @params = Culpa::EnvelopeRequest.new(opts) self end |
#with_session(hash) ⇒ Object
36 37 38 |
# File 'lib/culpa/test_helpers.rb', line 36 def with_session(hash) @session.merge!(hash) end |