substring("string").count only returns one or zero

Hi all -

I having an issue where substring(“string”).count only returns a one or a zero when checked with the .is method. I’m sure this is caused by my newness to Scala and Gatling, but I just can’t figure out what I’m doing wrong. According to the docs at: http://gatling.io/docs/2.1.4/http/http_check.html#http-response-body it seems like substring should return more than one result if the substring exists multiple times in the body. However, when I use the .regex method, I get the correct number of responses.

Here is my code:

import scala.concurrent.duration._
import io.gatling.core.Predef._
import io.gatling.http.Predef._
import io.gatling.jdbc.Predef._
import util.Random

class GetOne extends Simulation {

/* headers and credentials omitted */

val scn = scenario(“populate”)
.repeat(1) {
feed(userCreds)
.exec(http(“request - login”)
.post("")
.headers(headers_login)
.exec(http(“get offers”)
.get("<api_url>")
.headers(headers_save_deal)
.check(substring(“total”)
.count
.is(5))
)
.exec(flushSessionCookies)
}
setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

This gives me this output:

---- Errors --------------------------------------------------------------------

substring(save_for_later_offer_id).count.is(5), but actually f 1 (100.0%)

ound 1

Indeed a bug, thanks for reporting!

Fixed: https://github.com/gatling/gatling/issues/2571