Closed KrzysztofKowalczyk closed 5 years ago
Thanks for the clear discussion of the issue. This is the same as the underlying issue in #110 - I like your CharSequence
idea better than the method name change idea from the other ticket (e.g. GET
).
You are welcome to create a patch to address the issue, otherwise it will wait for v2.0.
I see that it actually works fine since 1.9.0
I've still created #118
Ah, I guess I forgot to ask my stock question of "what version are you using" :-) Thanks for the fix. I will take a look at it this week and get a release out.
I was pretty sure we are on latest version and we were, just in different project ;)
Fixed in 1.9.0
Stumbled up on this today. Using ersatz 1.9.0:safe@jar
, Groovy 2.5.13 and the below syntax fails:
server.expectations {
get("/some-url/${someVariable}") {
...
}
}
Currently working around by inlining the variable someVariable
in all my expectations.
Fails how? Please try it in 2.0.0 - if you still have the issue, please create a new issue with as much detail as possible including a failing test case or example code.
It tries to use a URL of /some-url/Expectation
and therefore none of my expectations are met. I cannot upgrade to 2.x immediately, but I know the new upper case method names in 2.x addresses it. I'll create a new issue for this.
I won't be making any bug fixes in the 1.9 line.
That's fine. It's not a major problem now. I'll prioritise upgrading to 2.x in our next internal milestone.
In the following example first test case fails but second passes.
The only difference is that first one is using global variable where the second one is using local variable:
This is most likely caused by this line: https://github.com/cjstehno/ersatz/blob/master/src/main/groovy/com/stehno/ersatz/Expectations.groovy#L98
get(String)
has special meaning in groovy as any unknown field would delegate resolution to this method to get a value. Together with DELEGATE_FIRST strategy it most likely calls this method instead of getting value from the owner.Hence in general avoid implementing get(String) methods in groovy.
If that's the problem, it has very simple fix, just change method signature to :
It will not break clients as String is a CharSequence but it would stop the issues.