Module: Fluxo::Rspec::InstanceMethods
- Defined in:
- lib/fluxo/rspec.rb
Instance Method Summary collapse
- #expect_operation_result(**attrs) ⇒ Object
- #expect_step_result(step_name, **kwargs) ⇒ Object
- #operation_result(**kwargs) ⇒ Object
- #step_result(step_name, **kwargs) ⇒ Object
Instance Method Details
#expect_operation_result(**attrs) ⇒ Object
140 141 142 |
# File 'lib/fluxo/rspec.rb', line 140 def expect_operation_result(**attrs) expect(operation_result(**attrs)) end |
#expect_step_result(step_name, **kwargs) ⇒ Object
149 150 151 |
# File 'lib/fluxo/rspec.rb', line 149 def expect_step_result(step_name, **kwargs) expect(step_result(step_name, **kwargs)) end |
#operation_result(**kwargs) ⇒ Object
144 145 146 147 |
# File 'lib/fluxo/rspec.rb', line 144 def operation_result(**kwargs) define_singleton_method(:result) { instance_variable_get(:@__result__) } @__result__ ||= described_class.call(**kwargs) end |
#step_result(step_name, **kwargs) ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/fluxo/rspec.rb', line 153 def step_result(step_name, **kwargs) @__operation__ = described_class.new define_singleton_method(:result) { instance_variable_get(:@__result__) } begin @__result__ = @__operation__.__execute_flow__(steps: [step_name], attributes: kwargs, validate: false) rescue => e @__result__ = Fluxo::Result.new(type: :exception, value: e, operation: @__operation__, ids: %i[error]) Fluxo::Errors.raise_operation_error!(result) end @__result__ end |