I have a transaction with an operation that is wrapped.
class Import
include Dry::Transaction(container: MyContainer)
step :store_product, with: 'product.store_product'
private
def store_product(input)
super(input) do |m|
m.success { |out| Success([input, output]) }
m.failure { |err| Failure(err) }
end
end
end
I want to test the method #store_product. So I want to inject the original operation by a mock operation.
Is it possible?
You can simply pass the mocked operation to your transaction constructor:
Rspec.describe Import do
include Dry::Monads::Result::Mixin
let(:import) { Import.new(store_product: ->(input) { Success(input) }
it 'will work' do
import.call('something')
end
end