7

I am testing the interaction between one object, and another object with some methods that have call-by-name arguments. However, I can't figure out how to create an argument matcher for that call-by-name argument.

Let's say that this is the signature of the mocked object:

def fn(arg1: => String, arg2: Int): Any

Then what I really want to do is test if that method is called with a known second argument. I don't even care all that much about the first argument, but having a way to properly test that as well would be a bonus.

This doesn't work:

there was one(mock) fn(any[()=>String], eq(12))

nor this:

there was one(mock) fn(any[Function0[String]], eq(12))

and this doesn't even compile:

there was one(mock) fn(any[=>String], eq(12)) ... which obviously is to be expected.

Wilfred Springer
  • 10,869
  • 4
  • 55
  • 69

1 Answers1

2

I've just added some support in specs2 for byname arguments and functions/partial function arguments. Please try out the latest specs2-1.9-SNAPSHOT and create an issue on GitHub if that doesn't work for you.

Eric
  • 15,494
  • 38
  • 61