Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking Operations #21

Open
richardboehme opened this issue Nov 28, 2022 · 0 comments
Open

Mocking Operations #21

richardboehme opened this issue Nov 28, 2022 · 0 comments

Comments

@richardboehme
Copy link
Collaborator

In some cases one might prefer to mock Operation calls. This might be helpful, when testing Operations that invoke Subprocesses that are not of interest in the test.

One example of doing this can be seen here (using the mocha gem):

signal = Song::Operation::Create.to_h[:outputs].find { |output| output.signal.to_h[:semantic] == :success }.signal
Song::Operation::Create.expects(:call).once.with do |(ctx, _)|
  !ctx[:name].empty? &&
    ctx[:length].to_i > 0
end.returns([signal, Trailblazer::Context({ song: Song.new })])

I believe we could benefit from providing a universial way of defining such expectations. The current way of doing this is kinda complicated:

  • You have to extract the correct signal instance from the operation yourself.
  • There are different call interfaces (when using in Subprocess vs. calling the operations yourself)
  • If you want to mock a Subprocess you have to know the circuit interface

It may be possible to provide a simpler interface which allows:

  • return different signals (by name/class?)
  • expect specific inputs
  • return a specific new context (which might depend on the inputs?) => define outputs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant