These are chat archives for dry-rb/chat

27th
Mar 2018
Spencer Goh
@dymaxionuk
Mar 27 2018 06:31

How are we supposed to mock operations?

class MyOp
  def call(inputs)
    // lightweight do something
    my_wrapped_op.call(stuff) do |m|
      m.success do |v|
         // do something
      end
    end
    // clean up and return stuff
  end
end

This however doesn't work because my_wrapped_op should call the block with a Dry::Matcher::Evaluator - my test however shouldn't get into the internals of dry operations.

expect MyOp.to_receive(:call) {|&block| block.call( Success('something') }

Am I approaching this wrong?

Gustavo Caso
@GustavoCaso
Mar 27 2018 07:45
Are we talking about dry-transaction? @dymaxionuk
Gustavo Caso
@GustavoCaso
Mar 27 2018 08:03
?
Nico Ritschel
@nicosuave
Mar 27 2018 22:11
Has anyone nested transactions with dry-transaction? I'm thinking this might provide a sane way to organize a moderately complex flow with lots of branching & provide more encapsulation/reusability. I.e. a single step in a parent transaction calls a child transaction
Nico Ritschel
@nicosuave
Mar 27 2018 22:27
I am not using operations containers, but rather local operations and anything common I have just been extracting into behvaior-centric modules, so perhaps I'm missing critical info here.
Tim Riley
@timriley
Mar 27 2018 23:27
@nicosuave I don’t see why you couldn’t use a transaction object as a step for another transaction