Forgus / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

ruby style test double support #314

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Currently there are 2 ways I know of for creating a mock in Spock.
A a = Mock()
def b = Mock(B)

The annoying thing with this approach is that it only works for existing types. 
Yet Groovy is a dynamic language so leaving out the type is a valid programming 
style but completely unsupported by most mocking libraries I know of.

In ruby you can do the following:

def a = double("a")
a.should_receive(:msg)

So I'd like to be able to do something similar in Spock. E.g:
def a = Mock("a")
1 * a.msg()

Original issue reported on code.google.com by s...@thinkerit.be on 29 May 2013 at 2:15

GoogleCodeExporter commented 8 years ago
See "Groovy Mocks" in the reference documentation 
(http://docs.spockframework.org/en/latest/interaction_based_testing.html#groovy-
mocks-new-in-0-7).

Original comment by pnied...@gmail.com on 29 May 2013 at 2:18

GoogleCodeExporter commented 8 years ago
Awesome. So I can do def a = GroovyMock(Object)
Thanks, and sorry for unnecessarily raising an issue.

Original comment by s...@thinkerit.be on 29 May 2013 at 2:24

GoogleCodeExporter commented 8 years ago
No problem. Let us know how Groovy mocks are working for you. We may eventually 
support `def a = GroovyMock()`, but it's not there yet.

Original comment by pnied...@gmail.com on 29 May 2013 at 2:30