Is one-go stub creation broken or am I using it wrong (or is there a typo in the docs)?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Is one-go stub creation broken or am I using it wrong (or is there a typo in the docs)?

Behrang Saeedzadeh
Hi,

According to the docs, I should be able to create a stub in one go like this:

import spock.lang.Specification

import java.awt.Dimension

public class WhyOhWhySpec extends Specification {

def "stubbing should work"() {
given:
def dimension = Stub(Dimension) {
getSize() << new Dimension(10, 10)
}

expect:
dimension.size.height == 10
dimension.size.width == 10
}

}

However, this test case crashes with the following error:

groovy.lang.MissingMethodException: No signature of method: foo.bar.baz.WhyOhWhySpec.getSize() is applicable for argument types: () values: []
Possible solutions: getAt(java.lang.String), getClass(), notify()

Interestingly, if I use the double right arrow operator, stubbing seems to be working. Is the use of double left arrows a typo in the documentation?

def subscriber = Stub(Subscriber) {
    receive("message1") >> "ok"
    receive("message2") >> "fail"
}

I am using version 1.1-groovy-2.4-rc-1 of Spock.

Thanks,
Behrang

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is one-go stub creation broken or am I using it wrong (or is there a typo in the docs)?

Spock Framework mailing list
Where do you see a typo? You are quoting a part of the documentation using the right-shift operator, but try to use the left-shift yourself. You should not be surprised that it does not work.

The right-shift operator is used for specifying what a method does or returns. Left-shift is rather used to assign lists of values to variables, e.g. in "where:" blocks, which is a compeletly different thing.

--
Alexander Kriegisch

Schillerplatz 6, 91315 Höchstadt, Germany
Tel +49 (9193) 52 76, Mob +49 (176) 20 53 07 02

2016-09-05 3:39 GMT+02:00 Behrang Saeedzadeh <[hidden email]>:
Hi,

According to the docs, I should be able to create a stub in one go like this:

import spock.lang.Specification

import java.awt.Dimension

public class WhyOhWhySpec extends Specification {

def "stubbing should work"() {
given:
def dimension = Stub(Dimension) {
getSize() << new Dimension(10, 10)
}

expect:
dimension.size.height == 10
dimension.size.width == 10
}

}

However, this test case crashes with the following error:

groovy.lang.MissingMethodException: No signature of method: foo.bar.baz.WhyOhWhySpec.getSize() is applicable for argument types: () values: []
Possible solutions: getAt(java.lang.String), getClass(), notify()

Interestingly, if I use the double right arrow operator, stubbing seems to be working. Is the use of double left arrows a typo in the documentation?

def subscriber = Stub(Subscriber) {
    receive("message1") >> "ok"
    receive("message2") >> "fail"
}

I am using version 1.1-groovy-2.4-rc-1 of Spock.

Thanks,
Behrang

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is one-go stub creation broken or am I using it wrong (or is there a typo in the docs)?

Steinar Haugen
In reply to this post by Behrang Saeedzadeh

Try changing

  getSize() << new Dimension(10, 10)

​to

  getSize() >> new Dimension(10, 10)

​-Steinar​

On Mon, Sep 5, 2016 at 3:39 AM, Behrang Saeedzadeh <[hidden email]> wrote:
Hi,

According to the docs, I should be able to create a stub in one go like this:

import spock.lang.Specification

import java.awt.Dimension

public class WhyOhWhySpec extends Specification {

def "stubbing should work"() {
given:
def dimension = Stub(Dimension) {
getSize() << new Dimension(10, 10)
}

expect:
dimension.size.height == 10
dimension.size.width == 10
}

}

However, this test case crashes with the following error:

groovy.lang.MissingMethodException: No signature of method: foo.bar.baz.WhyOhWhySpec.getSize() is applicable for argument types: () values: []
Possible solutions: getAt(java.lang.String), getClass(), notify()

Interestingly, if I use the double right arrow operator, stubbing seems to be working. Is the use of double left arrows a typo in the documentation?

def subscriber = Stub(Subscriber) {
    receive("message1") >> "ok"
    receive("message2") >> "fail"
}

I am using version 1.1-groovy-2.4-rc-1 of Spock.

Thanks,
Behrang

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Spock Framework - User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/spockframework.
For more options, visit https://groups.google.com/d/optout.
Loading...