Permalink
Browse files

Revert "Those tests are not valid behavior"

Whoops, lets not delete *ALL* the tests

This reverts commit 9e98390.
  • Loading branch information...
1 parent 9e98390 commit ae0fb4de39d1d2c01ce835c09d0de64a661545fa @dkowis dkowis committed Nov 20, 2013
@@ -33,4 +33,63 @@ class CustomMatcherSpec extends Specification {
return output
}
+
+ void "Using a custom matcher it should replay"() {
+ given:
+ def imr = new InstrumentedMatchRule()
+ def proxyConfig = ProxyConfiguration.builder()
+ .sslEnabled(true)
+ .tapeRoot(tapeRoot)
+ .defaultMode(TapeMode.READ_ONLY)
+ .defaultMatchRule(imr)
+ .build()
+
+ def recorder = new Recorder(proxyConfig)
+ recorder.start("httpBinTape")
+ imr.requestValidations << { r ->
+ //Will run this request validation on both requests being matched
+ //No matter what, either recorded, or sent, I should have a payload of "BUTTS"
+ //I'm posting "BUTTS" and the recorded interaction should have "BUTTS"
+ if(!r.hasBody() ){
+ println("REQUEST BODY WASNT THERE!!!")
+ }
+ }
+
+ when:
+ def response = simplePost("https://httpbin.org/post", "BUTTS")
+ then:
+ def content = response.toString()
+ recorder.stop()
+
+ content == "Hey look some text: BUTTS"
+ }
+
+ void "When the tape only contains a single entry in #mode, it should only match once"() {
+ given:
+ def imr = new InstrumentedMatchRule()
+ def proxyConfig = ProxyConfiguration.builder()
+ .sslEnabled(true)
+ .tapeRoot(tapeRoot)
+ .defaultMode(mode)
+ .defaultMatchRule(imr)
+ .build()
+
+ def recorder = new Recorder(proxyConfig)
+ recorder.start("httpBinTape")
+
+ when:
+ assert (imr.counter.get() == 0)
+ def response = simplePost("https://httpbin.org/post", "BUTTS")
+
+ then:
+ recorder.stop()
+
+ imr.counter.get() == 1
+ response == "Hey look some text: BUTTS"
+
+ where:
+ mode << [TapeMode.READ_ONLY, TapeMode.READ_WRITE]
+ }
+
+
}

0 comments on commit ae0fb4d

Please sign in to comment.