cholick / idea-spock-enhancements

A plugin for IntelliJ IDEA that improves integration with the Spock specification framework
Other
30 stars 10 forks source link

Spock DSL #21

Closed Vad1mo closed 9 years ago

Vad1mo commented 9 years ago

When using Groovy and Spock Specifications

I have the following code where groovy complains:

    def "load non existing user by username"() {
        when:
        userService.loadUserByUsername(user.email)

        then:
        1 * userRepositoryMock.findByEmail(this.user.email)
        1 * messageSource.getMessage("user.not.found",_,_) >> 'msg'
        UsernameNotFoundException e = thrown()
        e.message == "msg"
    }

For line 1 * messageSource.getMessage("user.not.found",_,_) >> 'msg'

it recommends to replace it with messageSource.getMessage("user.not.found",_,_) >> 'msg'

then it also sys here 1 * userRepositoryMock.findByEmail(this.user.email) that multiply can not be used.

In order to resolve this "issue" is a custom Groovy DSL needed or should the Groovy plugin handle that or the spock plugin?

cholick commented 9 years ago

This is fixed in the newest (13.1.5) version of IntelliJ, see issue IDEA-124864

Vad1mo commented 9 years ago

well then I must have a different 13.1.5 version

image

image

but thanks for the link to the issue. will try to reopen it.

cholick commented 9 years ago

You're right; I see my mistake. I'd found the issue in their tracker then didn't test sufficiently locally. Multiply looks fine when applied to a method that doesn't return a value; it's only problematic when mocking methods that return something.

Vad1mo commented 9 years ago

I created an issue at intellij,when I get an ticket number I will reply it here.

szpak commented 9 years ago

Isn't it that reopened issue https://youtrack.jetbrains.com/issue/IDEA-127650 ?

cholick commented 9 years ago

Yup, looks like it. Voted it up.

Vad1mo commented 9 years ago

this is not mine, but it looks like it is similar to mine.

Vad1mo commented 9 years ago

intellij support requested to install version 14. The multiply warning is gone rest is unchanged.

image